mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 14:41:23 -07:00
added docs to CLI docstringsadded
removed 'now intermediate build files' from repo adjusted gitignore
This commit is contained in:
parent
424e1946f4
commit
18a7a1ec31
21 changed files with 269 additions and 1803 deletions
|
@ -93,7 +93,7 @@ class InvalidOptsParser(SortedOptParser):
|
|||
class CLI(with_metaclass(ABCMeta, object)):
|
||||
''' code behind bin/ansible* programs '''
|
||||
|
||||
VALID_ACTIONS = ['No Actions']
|
||||
VALID_ACTIONS = []
|
||||
|
||||
_ITALIC = re.compile(r"I\(([^)]+)\)")
|
||||
_BOLD = re.compile(r"B\(([^)]+)\)")
|
||||
|
@ -283,7 +283,8 @@ class CLI(with_metaclass(ABCMeta, object)):
|
|||
|
||||
@staticmethod
|
||||
def base_parser(usage="", output_opts=False, runas_opts=False, meta_opts=False, runtask_opts=False, vault_opts=False, module_opts=False,
|
||||
async_opts=False, connect_opts=False, subset_opts=False, check_opts=False, inventory_opts=False, epilog=None, fork_opts=False, runas_prompt_opts=False, desc=None):
|
||||
async_opts=False, connect_opts=False, subset_opts=False, check_opts=False, inventory_opts=False, epilog=None, fork_opts=False,
|
||||
runas_prompt_opts=False, desc=None):
|
||||
''' create an options parser for most ansible scripts '''
|
||||
|
||||
# base opts
|
||||
|
@ -665,51 +666,3 @@ class CLI(with_metaclass(ABCMeta, object)):
|
|||
data = data.split(os.pathsep)[0]
|
||||
return data
|
||||
|
||||
def _opt_doc_list(self, action=None):
|
||||
''' generate options docs '''
|
||||
|
||||
if action:
|
||||
self.args.append(action)
|
||||
self.set_action()
|
||||
|
||||
results = []
|
||||
for opt in self.parser.option_list:
|
||||
res = {
|
||||
'desc': opt.help,
|
||||
'options': opt._short_opts + opt._long_opts
|
||||
}
|
||||
if opt.action == 'store':
|
||||
res['arg'] = opt.dest.upper()
|
||||
results.append(res)
|
||||
|
||||
return results
|
||||
|
||||
def opts_docs(self, args=None):
|
||||
''' generate doc structure from options '''
|
||||
|
||||
# cli name
|
||||
name = os.path.basename(sys.argv[0])
|
||||
if '-' in name:
|
||||
name = name.split('-')[1]
|
||||
else:
|
||||
name = 'adhoc'
|
||||
|
||||
# cli info
|
||||
docs = {
|
||||
'cli': name,
|
||||
'usage': self.parser.usage,
|
||||
'short_desc': self.parser.description
|
||||
}
|
||||
|
||||
if self.VALID_ACTIONS:
|
||||
myopts = []
|
||||
for action in self.VALID_ACTIONS:
|
||||
newopts = self._opt_doc_list(action)
|
||||
for nopt in newopts:
|
||||
if nopt not in myopts:
|
||||
myopts.append(nopt)
|
||||
docs['options'] = myopts
|
||||
else:
|
||||
docs['options'] = self._opt_doc_list()
|
||||
|
||||
return docs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue