Bug 1335620 - Don't assume "uninstall" means "install" r?gps
`mach install` is a command to install the package onto the device. People might assume that `mach uninstall` exists and does the opposite of `mach install`, but it doesn't.
When the user runs `mach uninstall`, mach helpfully looks for suggested similar commands, and picks `install` as the best option and immediately proceeds to run it.
This patch explicitly prevents mach from looking for suggestions when the entered command is `uninstall`.
MozReview-Commit-ID: 4Hpk8G23yTk
--- a/python/mach/mach/dispatcher.py
+++ b/python/mach/mach/dispatcher.py
@@ -416,17 +416,17 @@ class CommandAction(argparse.Action):
if h.cls.__name__ != 'DeprecatedCommands']
# We first try to look for a valid command that is very similar to the given command.
suggested_commands = difflib.get_close_matches(command, names, cutoff=0.8)
# If we find more than one matching command, or no command at all,
# we give command suggestions instead (with a lower matching threshold).
# All commands that start with the given command (for instance:
# 'mochitest-plain', 'mochitest-chrome', etc. for 'mochitest-')
# are also included.
- if len(suggested_commands) != 1:
+ if len(suggested_commands) != 1 or command == 'uninstall':
suggested_commands = set(difflib.get_close_matches(command, names, cutoff=0.5))
suggested_commands |= {cmd for cmd in names if cmd.startswith(command)}
raise UnknownCommandError(command, 'run', suggested_commands)
sys.stderr.write("We're assuming the '%s' command is '%s' and we're "
"executing it for you.\n\n" % (command, suggested_commands[0]))
return suggested_commands[0]