Generate code for flag types and context accessors

This commit is contained in:
Dan Buch
2016-06-23 00:56:44 -04:00
parent 4205e9c4ee
commit 6185b8d8fd
9 changed files with 682 additions and 450 deletions

View File

@@ -20,6 +20,7 @@ def main(sysargs=sys.argv[:]):
'test': _test,
'gfmxr': _gfmxr,
'toc': _toc,
'gen': _gen,
}
parser = argparse.ArgumentParser()
@@ -34,7 +35,7 @@ def main(sysargs=sys.argv[:]):
def _test():
if check_output('go version'.split()).split()[2] < 'go1.2':
_run('go test -v .'.split())
_run('go test -v .')
return
coverprofiles = []
@@ -51,7 +52,7 @@ def _test():
])
combined_name = _combine_coverprofiles(coverprofiles)
_run('go tool cover -func={}'.format(combined_name).split())
_run('go tool cover -func={}'.format(combined_name))
os.remove(combined_name)
@@ -60,15 +61,22 @@ def _gfmxr():
def _vet():
_run('go vet ./...'.split())
_run('go vet ./...')
def _toc():
_run(['node_modules/.bin/markdown-toc', '-i', 'README.md'])
_run(['git', 'diff', '--quiet'])
_run('node_modules/.bin/markdown-toc -i README.md')
_run('git diff --quiet')
def _gen():
_run('go generate .')
_run('git diff --quiet')
def _run(command):
if hasattr(command, 'split'):
command = command.split()
print('runtests: {}'.format(' '.join(command)), file=sys.stderr)
check_call(command)