本文整理汇总了Python中azure.cli.core.commands.CliCommand.help方法的典型用法代码示例。如果您正苦于以下问题:Python CliCommand.help方法的具体用法?Python CliCommand.help怎么用?Python CliCommand.help使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类azure.cli.core.commands.CliCommand
的用法示例。
在下文中一共展示了CliCommand.help方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_help_full_documentations
# 需要导入模块: from azure.cli.core.commands import CliCommand [as 别名]
# 或者: from azure.cli.core.commands.CliCommand import help [as 别名]
def test_help_full_documentations(self, _):
app = Application(Configuration())
def test_handler():
pass
command = CliCommand('n1', test_handler)
command.add_argument('foobar', '--foobar', '-fb', required=False)
command.add_argument('foobar2', '--foobar2', '-fb2', required=True)
command.help = """
short-summary: this module does xyz one-line or so
long-summary: |
this module.... kjsdflkj... klsfkj paragraph1
this module.... kjsdflkj... klsfkj paragraph2
parameters:
- name: --foobar -fb
type: string
required: false
short-summary: one line partial sentence
long-summary: text, markdown, etc.
populator-commands:
- az vm list
- default
- name: --foobar2 -fb2
type: string
required: true
short-summary: one line partial sentence
long-summary: paragraph(s)
examples:
- name: foo example
text: example details
"""
cmd_table = {'n1': command}
config = Configuration()
config.get_command_table = lambda args: cmd_table
app = Application(config)
with self.assertRaises(SystemExit):
app.execute('n1 -h'.split())
s = """
Command
az n1: This module does xyz one-line or so.
This module.... kjsdflkj... klsfkj paragraph1
this module.... kjsdflkj... klsfkj paragraph2.
Arguments
--foobar2 -fb2 [Required]: One line partial sentence.
Paragraph(s).
--foobar -fb : One line partial sentence. Values from: az vm list, default.
Text, markdown, etc.
Global Arguments
--help -h : Show this help message and exit.
Examples
foo example
example details
"""
self.assertEqual(s, io.getvalue())
示例2: test_help_global_params
# 需要导入模块: from azure.cli.core.commands import CliCommand [as 别名]
# 或者: from azure.cli.core.commands.CliCommand import help [as 别名]
def test_help_global_params(self, mock_register_extensions, _):
def register_globals(global_group):
global_group.add_argument(
"--query2",
dest="_jmespath_query",
metavar="JMESPATH",
help="JMESPath query string. See http://jmespath.org/ " "for more information and examples.",
)
mock_register_extensions.return_value = None
def _register_global_parser(appl):
# noqa pylint: disable=protected-access
appl._event_handlers[appl.GLOBAL_PARSER_CREATED].append(register_globals)
mock_register_extensions.side_effect = _register_global_parser
def test_handler():
pass
command = CliCommand("n1", test_handler)
command.add_argument("arg", "--arg", "-a", required=False)
command.add_argument("b", "-b", required=False)
command.help = """
long-summary: |
line1
line2
"""
cmd_table = {"n1": command}
config = Configuration([])
config.get_command_table = lambda: cmd_table
app = Application(config)
with self.assertRaises(SystemExit):
app.execute("n1 -h".split())
s = """
Command
az n1
Line1
line2.
Arguments
--arg -a
-b
Global Arguments
--help -h: Show this help message and exit.
--query2 : JMESPath query string. See http://jmespath.org/ for more information and examples.
"""
self.assertEqual(s, io.getvalue())
示例3: test_help_params_documentations
# 需要导入模块: from azure.cli.core.commands import CliCommand [as 别名]
# 或者: from azure.cli.core.commands.CliCommand import help [as 别名]
def test_help_params_documentations(self, _):
app = Application(Configuration())
def test_handler():
pass
command = CliCommand('n1', test_handler)
command.add_argument('foobar', '--foobar', '-fb', required=False)
command.add_argument('foobar2', '--foobar2', '-fb2', required=True)
command.add_argument('foobar3', '--foobar3', '-fb3', required=False, help='the foobar3')
command.help = """
parameters:
- name: --foobar -fb
type: string
required: false
short-summary: one line partial sentence
long-summary: text, markdown, etc.
populator-commands:
- az vm list
- default
- name: --foobar2 -fb2
type: string
required: true
short-summary: one line partial sentence
long-summary: paragraph(s)
"""
cmd_table = {'n1': command}
config = Configuration()
config.get_command_table = lambda argv: cmd_table
app = Application(config)
with self.assertRaises(SystemExit):
app.execute('n1 -h'.split())
s = """
Command
az n1
Arguments
--foobar2 -fb2 [Required]: One line partial sentence.
Paragraph(s).
--foobar -fb : One line partial sentence. Values from: az vm list, default.
Text, markdown, etc.
--foobar3 -fb3 : The foobar3.
Global Arguments
--help -h : Show this help message and exit.
"""
self.assertEqual(s, io.getvalue())
示例4: test_help_global_params
# 需要导入模块: from azure.cli.core.commands import CliCommand [as 别名]
# 或者: from azure.cli.core.commands.CliCommand import help [as 别名]
def test_help_global_params(self, mock_register_extensions, _):
def register_globals(global_group):
global_group.add_argument('--query2', dest='_jmespath_query', metavar='JMESPATH',
help='JMESPath query string. See http://jmespath.org/ '
'for more information and examples.')
mock_register_extensions.return_value = None
mock_register_extensions.side_effect = lambda app: \
app._event_handlers[app.GLOBAL_PARSER_CREATED].append(register_globals) # pylint: disable=protected-access
def test_handler():
pass
command = CliCommand('n1', test_handler)
command.add_argument('arg', '--arg', '-a', required=False)
command.add_argument('b', '-b', required=False)
command.help = """
long-summary: |
line1
line2
"""
cmd_table = {'n1': command}
config = Configuration([])
config.get_command_table = lambda: cmd_table
app = Application(config)
with self.assertRaises(SystemExit):
app.execute('n1 -h'.split())
s = """
Command
az n1
Line1
line2.
Arguments
--arg -a
-b
Global Arguments
--help -h: Show this help message and exit.
--query2 : JMESPath query string. See http://jmespath.org/ for more information and examples.
"""
self.assertEqual(s, io.getvalue())
示例5: test_help_docstring_description_overrides_short_description
# 需要导入模块: from azure.cli.core.commands import CliCommand [as 别名]
# 或者: from azure.cli.core.commands.CliCommand import help [as 别名]
def test_help_docstring_description_overrides_short_description(self):
def test_handler():
pass
command = CliCommand('n1', test_handler, description='short description')
command.add_argument('arg', '--arg', '-a', required=False)
command.add_argument('b', '-b', required=False)
command.help = 'short-summary: docstring summary'
cmd_table = {'n1': command}
config = Configuration([])
config.get_command_table = lambda: cmd_table
app = Application(config)
with self.assertRaises(SystemExit):
app.execute('n1 -h'.split())
self.assertEqual(True, 'n1: Docstring summary.' in io.getvalue())
示例6: test_help_long_description_and_short_description
# 需要导入模块: from azure.cli.core.commands import CliCommand [as 别名]
# 或者: from azure.cli.core.commands.CliCommand import help [as 别名]
def test_help_long_description_and_short_description(self):
def test_handler():
pass
command = CliCommand('n1', test_handler, description='short description')
command.add_argument('arg', '--arg', '-a', required=False)
command.add_argument('b', '-b', required=False)
command.help = 'long description'
cmd_table = {'n1': command}
config = Configuration([])
config.get_command_table = lambda: cmd_table
app = Application(config)
with self.assertRaises(SystemExit):
app.execute('n1 -h'.split())
self.assertEqual(True, io.getvalue().startswith('\nCommand\n az n1: Short description.\n Long description.')) # pylint: disable=line-too-long
示例7: test_help_long_description_and_short_description
# 需要导入模块: from azure.cli.core.commands import CliCommand [as 别名]
# 或者: from azure.cli.core.commands.CliCommand import help [as 别名]
def test_help_long_description_and_short_description(self):
def test_handler():
pass
command = CliCommand("n1", test_handler, description="short description")
command.add_argument("arg", "--arg", "-a", required=False)
command.add_argument("b", "-b", required=False)
command.help = "long description"
cmd_table = {"n1": command}
config = Configuration([])
config.get_command_table = lambda: cmd_table
app = Application(config)
with self.assertRaises(SystemExit):
app.execute("n1 -h".split())
self.assertEqual(
True, io.getvalue().startswith("\nCommand\n az n1: Short description.\n Long description.")
) # pylint: disable=line-too-long
示例8: test_help_long_description_multi_line
# 需要导入模块: from azure.cli.core.commands import CliCommand [as 别名]
# 或者: from azure.cli.core.commands.CliCommand import help [as 别名]
def test_help_long_description_multi_line(self):
def test_handler():
pass
command = CliCommand('n1', test_handler)
command.add_argument('arg', '--arg', '-a', required=False)
command.add_argument('b', '-b', required=False)
command.help = """
long-summary: |
line1
line2
"""
cmd_table = {'n1': command}
config = Configuration([])
config.get_command_table = lambda: cmd_table
app = Application(config)
with self.assertRaises(SystemExit):
app.execute('n1 -h'.split())
self.assertEqual(True, io.getvalue().startswith('\nCommand\n az n1\n Line1\n line2.')) # pylint: disable=line-too-long
示例9: test_help_group_help
# 需要导入模块: from azure.cli.core.commands import CliCommand [as 别名]
# 或者: from azure.cli.core.commands.CliCommand import help [as 别名]
def test_help_group_help(self):
app = Application(Configuration([]))
def test_handler():
pass
azure.cli.core.help_files.helps['test_group1 test_group2'] = """
type: group
short-summary: this module does xyz one-line or so
long-summary: |
this module.... kjsdflkj... klsfkj paragraph1
this module.... kjsdflkj... klsfkj paragraph2
examples:
- name: foo example
text: example details
"""
command = CliCommand('test_group1 test_group2 n1', test_handler)
command.add_argument('foobar', '--foobar', '-fb', required=False)
command.add_argument('foobar2', '--foobar2', '-fb2', required=True)
command.help = """
short-summary: this module does xyz one-line or so
long-summary: |
this module.... kjsdflkj... klsfkj paragraph1
this module.... kjsdflkj... klsfkj paragraph2
parameters:
- name: --foobar -fb
type: string
required: false
short-summary: one line partial sentence
long-summary: text, markdown, etc.
populator-commands:
- az vm list
- default
- name: --foobar2 -fb2
type: string
required: true
short-summary: one line partial sentence
long-summary: paragraph(s)
examples:
- name: foo example
text: example details
"""
cmd_table = {'test_group1 test_group2 n1': command}
config = Configuration([])
config.get_command_table = lambda: cmd_table
app = Application(config)
with self.assertRaises(SystemExit):
app.execute('test_group1 test_group2 --help'.split())
s = """
Group
az test_group1 test_group2: This module does xyz one-line or so.
This module.... kjsdflkj... klsfkj paragraph1
this module.... kjsdflkj... klsfkj paragraph2.
Commands:
n1: This module does xyz one-line or so.
Examples
foo example
example details
"""
self.assertEqual(s, io.getvalue())
del azure.cli.core.help_files.helps['test_group1 test_group2']