Example #1
0
 def get_command_table(self):  # pylint: disable=no-self-use
     import azure.cli.core.commands as commands
     # Find the first noun on the command line and only load commands from that
     # module to improve startup time.
     for a in self.argv:
         if not a.startswith('-'):
             return commands.get_command_table(a)
     # No noun found, so load all commands.
     return commands.get_command_table()
Example #2
0
 def get_command_table(self):
     import azure.cli.core.commands as commands
     # Find the first noun on the command line and only load commands from that
     # module to improve startup time.
     for a in self.argv:
         if not a.startswith('-'):
             return commands.get_command_table(a)
     # No noun found, so load all commands.
     return  commands.get_command_table()
Example #3
0
    def get_command_table(self, argv=None):  # pylint: disable=no-self-use
        import azure.cli.core.commands as commands
        # Find the first noun on the command line and only load commands from that
        # module to improve startup time.
        result = commands.get_command_table(argv[0].lower() if argv else None)

        if argv is None:
            return result

        command_tree = Configuration.build_command_tree(result)
        matches = Configuration.find_matches(argv, command_tree)
        return dict(matches)
Example #4
0
    def get_command_table(self, argv=None):  # pylint: disable=no-self-use
        import azure.cli.core.commands as commands
        # Find the first noun on the command line and only load commands from that
        # module to improve startup time.
        result = commands.get_command_table(argv[0].lower() if argv else None)

        if argv is None:
            return result

        command_tree = Configuration.build_command_tree(result)
        matches = Configuration.find_matches(argv, command_tree)
        return dict(matches)
Example #5
0
 def get_command_table(self):  # pylint: disable=no-self-use
     import azure.cli.core.commands as commands
     return commands.get_command_table()
Example #6
0
 def get_command_table(self):  # pylint: disable=no-self-use
     import azure.cli.core.commands as commands
     return commands.get_command_table()
def build_command_table():
    import azure.cli.core.commands as commands
    cmd_table = commands.get_command_table()
    for cmd in cmd_table:
        cmd_table[cmd].load_arguments()
    _update_command_definitions(cmd_table)

    data = {}
    for cmd in cmd_table:
        com_descip = {}
        param_descrip = {}
        com_descip['short-summary'] = cmd_table[cmd].description() \
            if callable(cmd_table[cmd].description) \
            else cmd_table[cmd].description or ''
        com_descip['examples'] = ''

        for key in cmd_table[cmd].arguments:
            required = ''
            help_desc = ''
            if cmd_table[cmd].arguments[key].type.settings.get('required'):
                required = '[REQUIRED]'
            if cmd_table[cmd].arguments[key].type.settings.get('help'):
                help_desc = cmd_table[cmd].arguments[key].type.settings.get('help')

            name_options = []
            for name in cmd_table[cmd].arguments[key].options_list:
                name_options.append(name)

            options = {
                'name': name_options,
                'required': required,
                'help': help_desc
            }
            param_descrip[cmd_table[cmd].arguments[key].options_list[0]] = options

        com_descip['parameters'] = param_descrip
        data[cmd] = com_descip

    for cmd in helps:
        diction_help = yaml.load(helps[cmd])
        if cmd not in data:
            data[cmd] = {
                'short-summary': diction_help.get(
                    'short-summary', ''),
                'long-summary': diction_help.get('long-summary', ''),
                'parameters': {}
            }
        else:
            data[cmd]['short-summary'] = diction_help.get('short-summary',
                                                          data[cmd].get('short-summary', ''))
            data[cmd]['long-summary'] = diction_help.get("long-summary", '')
            data[cmd]['parameters'] = {}

        if 'parameters' in diction_help:
            for param in diction_help["parameters"]:
                if param['name'].split()[0] not in data[cmd]['parameters']:
                    options = {
                        'name': name_options,
                        'required': required,
                        'help': help_desc
                    }
                    data[cmd]['parameters'] = {
                        param["name"].split()[0]: options
                    }
                if 'short-summary' in param:
                    data[cmd]['parameters'][param['name'].split()[0]]['help'] \
                        = param['short-summary']
        if 'examples' in diction_help:
            string_example = ''
            for example in diction_help['examples']:
                string_example += example.get('name', '') + '\n' + example.get('text', '') + '\n'
            data[cmd]['examples'] = string_example

    return data