mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Support -d
on the salt
binary. Fixes #1992.
This commit is contained in:
parent
06c3086102
commit
8c6b96db59
2 changed files with 24 additions and 1 deletions
|
@ -688,6 +688,15 @@ class SaltCMDOptionParser(OptionParser, ConfigDirMixIn, TimeoutMixIn,
|
|||
'Execute a salt command query, this can be used to find '
|
||||
'the results of a previous function call: -Q test.echo')
|
||||
)
|
||||
self.add_option(
|
||||
'-d', '--doc', '--documentation',
|
||||
dest='doc',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help=('Return the documentation for the specified module or for '
|
||||
'all modules if none are specified.')
|
||||
)
|
||||
|
||||
|
||||
def _mixin_after_parsed(self):
|
||||
if self.options.query:
|
||||
|
@ -698,10 +707,16 @@ class SaltCMDOptionParser(OptionParser, ConfigDirMixIn, TimeoutMixIn,
|
|||
self.config['cmd'] = self.args[0]
|
||||
else:
|
||||
# Catch invalid invocations of salt such as: salt run
|
||||
if len(self.args) <= 1:
|
||||
if len(self.args) <= 1 and not self.options.doc:
|
||||
self.print_help()
|
||||
self.exit(1)
|
||||
|
||||
if self.options.doc:
|
||||
# Include the target
|
||||
self.args.insert(0, '*')
|
||||
# Include the function
|
||||
self.args.insert(1, 'sys.doc')
|
||||
|
||||
if self.options.list:
|
||||
self.config['tgt'] = self.args[0].split(',')
|
||||
else:
|
||||
|
|
|
@ -116,6 +116,14 @@ class MatchTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
|
|||
data = '\n'.join(data)
|
||||
self.assertIn('minion', data)
|
||||
|
||||
def test_salt_documentation(self):
|
||||
'''
|
||||
Test to see if we're supporting --doc
|
||||
'''
|
||||
data = self.run_salt('-d user.add')
|
||||
self.assertIn('user.add:', data)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
loader = TestLoader()
|
||||
|
|
Loading…
Add table
Reference in a new issue