summaryrefslogtreecommitdiff
path: root/lib/ansible/cli
diff options
context:
space:
mode:
authorMichael Scherer <mscherer@users.noreply.github.com>2016-06-03 15:53:41 +0200
committerBrian Coca <bcoca@ansible.com>2016-06-03 09:53:41 -0400
commitf07d6b26a7a4b694d6fe5e2708cbfd72e0b3cd17 (patch)
tree2ee70384b703d150e5efa09beec24931e2cbe8a4 /lib/ansible/cli
parent2bf2e0fdfdb7293e28e3bb0543b2d0d14a65169f (diff)
downloadansible-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.py5
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)