Handle too many arguments for docs in salt-call. Refs #12261.

This commit is contained in:
Pedro Algarvio 2014-04-24 15:56:58 +01:00
parent 762d0b1e24
commit f3fa2aef74
2 changed files with 11 additions and 2 deletions

View file

@ -2044,8 +2044,7 @@ class SaltCallOptionParser(OptionParser, ConfigDirMixIn, MergeConfigMixIn,
)
def _mixin_after_parsed(self):
if not self.args and not self.options.grains_run \
and not self.options.doc:
if not self.args and not self.options.grains_run and not self.options.doc:
self.print_help()
self.exit(1)
@ -2053,6 +2052,9 @@ class SaltCallOptionParser(OptionParser, ConfigDirMixIn, MergeConfigMixIn,
if self.options.grains_run:
self.error('-g/--grains does not accept any arguments')
if self.options.doc and len(self.args) > 1:
self.error('You can only get documentation for one method at one time')
self.config['fun'] = self.args[0]
self.config['arg'] = self.args[1:]

View file

@ -58,6 +58,13 @@ class CallTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
''.join(ret)
)
def test_salt_documentation_too_many_arguments(self):
'''
Test to see if passing additional arguments shows an error
'''
data = self.run_call('-d salt ldap.search "filter=ou=People"', catch_stderr=True)
self.assertIn('You can only get documentation for one method at one time', '\n'.join(data[1]))
def test_issue_6973_state_highstate_exit_code(self):
'''
If there is no tops/master_tops or state file matches