diff options
author | Michael Scherer <mscherer@users.noreply.github.com> | 2016-06-03 15:53:41 +0200 |
---|---|---|
committer | Brian Coca <bcoca@ansible.com> | 2016-06-03 09:53:41 -0400 |
commit | f07d6b26a7a4b694d6fe5e2708cbfd72e0b3cd17 (patch) | |
tree | 2ee70384b703d150e5efa09beec24931e2cbe8a4 /lib/ansible/cli | |
parent | 2bf2e0fdfdb7293e28e3bb0543b2d0d14a65169f (diff) | |
download | ansible-f07d6b26a7a4b694d6fe5e2708cbfd72e0b3cd17.tar.gz |
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'.
Diffstat (limited to 'lib/ansible/cli')
-rw-r--r-- | lib/ansible/cli/adhoc.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/ansible/cli/adhoc.py b/lib/ansible/cli/adhoc.py index d4f917f2c2..862bfd107d 100644 --- a/lib/ansible/cli/adhoc.py +++ b/lib/ansible/cli/adhoc.py @@ -74,9 +74,12 @@ class AdHocCLI(CLI): 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") + if len(self.args) > 1: + raise AnsibleOptionsError("Extranous options or arguments") + display.verbosity = self.options.verbosity self.validate_conflicts(runas_opts=True, vault_opts=True, fork_opts=True) |