#!/usr/bin/env python
"""
install recursively inspects every *.go file in the current
working directory and replaces "github.com/suyashkumar/go-starter"
with whatever is supplied as the first command line argument.

This is used to update the import path for subpackages in this starter
repo to a new path.
"""
import os, fnmatch, sys

if __name__ == '__main__':
	for path, dirs, files in os.walk(os.getcwd()):
		for filename in fnmatch.filter(files, "*.go"):
			filepath = os.path.join(path, filename)
			with open(filepath) as f:
				s = f.read()
			s = s.replace("github.com/suyashkumar/go-starter", sys.argv[1])
			with open(filepath, "w") as f:
				f.write(s)
	os.remove(sys.argv[0]) # Delete install at the end of installation
