From d05e5fb09fabf1225c59dc885a2e7ff3db4c4405 Mon Sep 17 00:00:00 2001 From: "rdsmith@google.com" Date: Fri, 30 Jul 2010 20:44:14 +0000 Subject: [PATCH] 'git try': a) Give users help when they ask for it, b) Don't start try job if you don't understand the command. BUG=none TEST=Make change in local sandbox and confirm proper things happen on "git try help", "git try xyzzy", and "git try -b linux." Review URL: http://codereview.chromium.org/3075009 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@54374 0039d316-1c4b-4281-b951-d872f2087c98 --- trychange.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/trychange.py b/trychange.py index ed6afa65e..b16095517 100755 --- a/trychange.py +++ b/trychange.py @@ -600,8 +600,24 @@ def TryChange(argv, parser.add_option_group(group) options, args = parser.parse_args(argv) - if len(args) == 1 and args[0] == 'help': + + # Note that the args array includes the script name, so + # a single argument results in len(args) == 2. + + # If they've asked for help, give it to them + if len(args) == 2 and args[1] == 'help': + parser.print_help() + return 0 + + # If they've said something confusing, don't spawn a try job until you + # understand what they want. + if len(args) > 1: + plural = "" + if len(args) > 2: + plural = "s" + print "Argument%s \"%s\" not understood" % (plural, " ".join(args[1:])) parser.print_help() + return 1 LOG_FORMAT = '%(levelname)s %(filename)s(%(lineno)d): %(message)s' if not swallow_exception: