Allow zero+ paths in migration script

and run the self-tests on Windows, too.
This commit is contained in:
Dan Buch 2016-05-30 10:46:00 -04:00
parent 6d59b40b68
commit 462217f9fc
No known key found for this signature in database
GPG Key ID: FAEF12936DD3E3EC
2 changed files with 8 additions and 3 deletions

View File

@ -23,3 +23,4 @@ build_script:
- python runtests vet
- python runtests test
- python runtests gfmxr
- python cli-v1-to-v2 --selftest

View File

@ -36,7 +36,7 @@ def main(sysargs=sys.argv[:]):
parser = argparse.ArgumentParser(
description=_DESCRIPTION,
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('path', nargs='+',
parser.add_argument('path', nargs='*',
type=os.path.abspath, default=os.getcwd())
parser.add_argument('-w', '--write', help='write changes back to file',
action='store_true', default=False)
@ -60,7 +60,11 @@ def main(sysargs=sys.argv[:]):
format='%(message)s'
)
for filepath in _find_candidate_files(args.path):
paths = args.path
if len(paths) == 0:
paths = ['.']
for filepath in _find_candidate_files(paths):
updated_source = _update_filepath(filepath)
if args.write:
logging.info('Updating %s', filepath)
@ -86,7 +90,7 @@ def _find_candidate_files(paths):
dirs.pop(i)
for filename in files:
if not filename.endswith('.go'):
if not filename.decode('utf-8').endswith('.go'):
continue
filepath = os.path.join(curdir, filename)