Show a better error message when there is too much arguments (#16119)

If someone run:

  ansible all -m file state=present

The error message is "Missing target hosts" which is misleading, since
the target hosts is here, the problem is the missing '-a'.
pull/16126/head
Michael Scherer 9 years ago committed by Brian Coca
parent 2bf2e0fdfd
commit f07d6b26a7

@ -74,9 +74,12 @@ class AdHocCLI(CLI):
self.options, self.args = self.parser.parse_args(self.args[1:]) self.options, self.args = self.parser.parse_args(self.args[1:])
if len(self.args) != 1: if len(self.args) < 1:
raise AnsibleOptionsError("Missing target hosts") raise AnsibleOptionsError("Missing target hosts")
if len(self.args) > 1:
raise AnsibleOptionsError("Extranous options or arguments")
display.verbosity = self.options.verbosity display.verbosity = self.options.verbosity
self.validate_conflicts(runas_opts=True, vault_opts=True, fork_opts=True) self.validate_conflicts(runas_opts=True, vault_opts=True, fork_opts=True)

Loading…
Cancel
Save