From f07d6b26a7a4b694d6fe5e2708cbfd72e0b3cd17 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Fri, 3 Jun 2016 15:53:41 +0200 Subject: [PATCH] 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'. --- lib/ansible/cli/adhoc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/cli/adhoc.py b/lib/ansible/cli/adhoc.py index d4f917f2c26..862bfd107d6 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)