1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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'.
This commit is contained in:
Michael Scherer 2016-06-03 15:53:41 +02:00 committed by Brian Coca
parent 2bf2e0fdfd
commit f07d6b26a7

View file

@ -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)