If cit is run with an unknown tool, print usage rather than throwing an exception

BUG=
TBR=hinoka

Review-Url: https://codereview.chromium.org/2181413004
changes/90/365990/1
dsansome 9 years ago committed by Commit bot
parent 9d5696da80
commit 72decfedaa

@ -99,8 +99,28 @@ def get_available_tools():
return (sorted(infra_tools), sorted(cipd_tools))
def usage():
infra_tools, cipd_tools = get_available_tools()
print """usage: cit.py <name of tool> [args for tool]
Wrapper for maintaining and calling tools in:
"infra.git/run.py infra.tools.*"
"infra.git/cipd/*"
Available infra tools are:"""
for tool in infra_tools:
print ' * %s' % tool
print """
Available cipd tools are:"""
for tool in cipd_tools:
print ' * %s' % tool
def run(args):
if args:
if not args:
return usage()
tool_name = args[0]
# Check to see if it is a infra tool first.
infra_dir = os.path.join(
@ -115,28 +135,14 @@ def run(args):
'infra.tools.%s' % tool_name]
elif os.path.isfile(cipd_file) and is_exe(cipd_file):
cmd = [cipd_file]
else:
print >>sys.stderr, 'Unknown tool "%s"' % tool_name
return usage()
# Add the remaining arguments.
cmd.extend(args[1:])
return subprocess.call(cmd)
infra_tools, cipd_tools = get_available_tools()
print """usage: cit.py <name of tool> [args for tool]
Wrapper for maintaining and calling tools in:
"infra.git/run.py infra.tools.*"
"infra.git/cipd/*"
Available infra tools are:"""
for tool in infra_tools:
print ' * %s' % tool
print """
Available cipd tools are:"""
for tool in cipd_tools:
print ' * %s' % tool
def main():
parser = argparse.ArgumentParser("Chrome Infrastructure CLI.")

Loading…
Cancel
Save