brings up the metadata for the command if there is a valid command already typed
485089
def on_input_timeout(self, cli):
        
        document = cli.current_buffer.document
        text = document.text

        text = text.replace('az ', '')
        if self.default_command:
            text = self.default_command + ' ' + text

        param_info, example = self.generate_help_text()

        self.param_docs = u'{}'.format(param_info)
        self.example_docs = u'{}'.format(example)

        self._update_default_info()

        cli.buffers['description'].reset(
            initial_document=Document(self.description_docs, cursor_position=0))
        cli.buffers['parameter'].reset(
            initial_document=Document(self.param_docs))
        cli.buffers['examples'].reset(
            initial_document=Document(self.example_docs))
        cli.buffers['default_values'].reset(
            initial_document=Document(
                u'{}'.format(self.config_default if self.config_default else 'No Default Values')))
        self._update_toolbar()
        cli.request_redraw()
51042
def match(command, options, args):
    """"""
    build = ""
    possible = commands
    for l in command:
        build += l
        possible = filter(lambda w: w.startswith(build), possible)
    
    if len(possible) == 0:
        raise ArgError("Command invalid: %s" % command)
    
    if len(possible) > 1:
        raise ArgError("Ambiguous command: %s" % command)

    command = possible.pop()

    if not num_args[command](len(args)):
        raise ArgError("Bad number of args for command %s" % command)

    return command
29448
def commandify(use_argcomplete=False, exit=True, *args, **kwargs):
    ''''''
    parser = CommandifyArgumentParser(*args, **kwargs)
    parser.setup_arguments()
    if use_argcomplete:
        try:
            import argcomplete
        except ImportError:
            print('argcomplete not installed, please install it.')
            parser.exit(status=2)
        # Must happen between setup_arguments() and parse_args().
        argcomplete.autocomplete(parser)
    args = parser.parse_args()
    if exit:
        parser.dispatch_commands()
        parser.exit(0)
    else:
        return parser.dispatch_commands()
525903
def add_custom_metadata(self, key, value, meta_type=None):
        
        self.metadata.append({'key': key, 'value': value, 'type': meta_type})
818388
def add_click_commands(module, cli, command_dict, namespaced):
    """"""
    module_commands = [
        item for item in getmembers(module)
        if isinstance(item[1], BaseCommand)
    ]
    options = command_dict.get('config', {})
    namespace = command_dict.get('namespace')
    for name, function in module_commands:
        f_options = options.get(name, {})
        command_name = f_options.get('name', getattr(function, 'name', name))
        if namespace:
            command_name = '{}_{}'.format(namespace, command_name)
        elif namespaced:
            module_namespace = module.__name__.split('.')[-1]
            command_name = '{}_{}'.format(module_namespace, command_name)
        function.short_help = f_options.get('help_text', function.short_help)
        cli.add_command(function, name=command_name)
1157170
def _update_metadata(self, kwargs=None):
        '''
        '''

        # If not given metadata, use instance.list to get it for container
        if kwargs == None and hasattr(self, 'name'):
            kwargs = self._list(self.name, quiet=True, return_json=True)

        # Add acceptable arguments
        for arg in ['pid', 'name']:

           # Skip over non-iterables:
           if arg in kwargs:
               setattr(self, arg, kwargs[arg])
       
        if "image" in kwargs:
            self._image = kwargs['image']
        elif "container_image" in kwargs:
            self._image = kwargs['container_image']
1109230
def cli(ctx):
    """"""
    cmd = click.prompt('Command')
    desc = click.prompt('Description ')
    alias = click.prompt('Alias (optional)', default='')
    utils.save_command(cmd, desc, alias)

    utils.log(ctx, 'Saved the new command - {} - with the description - {}.'.format(cmd, desc))
364638
def _parse_metadata(self, meta):
        """"""
        formatted_fields = self.settings['FORMATTED_FIELDS']

        output = collections.OrderedDict()
        for name, value in meta.items():
            name = name.lower()
            if name in formatted_fields:
                rendered = self._render(value).strip()
                output[name] = self.process_metadata(name, rendered)
            else:
                output[name] = self.process_metadata(name, value)
        return output
37601
def help(self, event, command_name=None):
        
        if command_name is None:
            return ("Type !commands for a list of all commands. Type "
                    "!help [command] to see help for a specific command.")
        try:
            command = self.commands_dict()[command_name]
        except KeyError:
            return "%s is not a command" % command_name

        argspec = getargspec(command)
        args = argspec.args[2:]
        defaults = argspec.defaults or []
        for i in range(-1, -len(defaults) - 1, -1):
            args[i] = "%s [default: %s]" % (args[i], defaults[i])
        args = ", ".join(args)
        help = getdoc(command).replace("\n", " ")
        return "help for %s: (args: %s) %s" % (command_name, args, help)
839631
def complete(metadata = {}, options = {})
      unless completable? || options.fetch(:force, false)
        raise NotCompletable.new(not_completable_error_message)
      end
      with_hooks(:update, metadata, options) do
        with_hooks(:complete, metadata, options) do
          proceed_workitem
          log(:complete, metadata)
        end
      end
    end
1360741
function (cmd) {
    var cmdName = dotty.get(cmd, this.definitions.command.name);

    if (!cmdName) {
      var err = new Error('command has no command name in ' + this.definitions.command.name);
      debug(err);
      throw err;
    }

    var version = 0;
    if (!!this.definitions.command.version) {
      version = dotty.get(cmd, this.definitions.command.version);
    }

    var command = this.getCommand(cmdName, version);
    if (!command) {
      var aggregateId = dotty.get(cmd, this.definitions.command.aggregateId);
      var aggregateName = this.name;
      var contextName = this.context.name;

      return [{
        context: contextName,
        aggregate: aggregateName,
        aggregateId: aggregateId
      }];
    }

    return command.getLoadInfo(cmd);
  }
1321042
def _filter_commands(ctx, commands=None):
    """"""
    lookup = getattr(ctx.command, 'commands', {})
    if not lookup and isinstance(ctx.command, click.MultiCommand):
        lookup = _get_lazyload_commands(ctx.command)

    if commands is None:
        return sorted(lookup.values(), key=lambda item: item.name)

    names = [name.strip() for name in commands.split(',')]
    return [lookup[name] for name in names if name in lookup]
1175462
def _add(self, command, *args, **kwargs):
        
        if self.indexable:
            self.index(args)
        return self._traverse_command(command, *args, **kwargs)
188573
def has_metadata(self, name):
        
        return self.has_implementation(name) or \
            name in self.non_returning or \
            name in self.prototypes
413093
def add_command(self, cmd_name, *args):
        """"""
        self.__commands.append(Command(cmd_name, args))
1285687
def has_metadata(source, ext):
    """"""
    _MMD_LIB.has_metadata.argtypes = [ctypes.c_char_p, ctypes.c_int]
    _MMD_LIB.has_metadata.restype = ctypes.c_bool
    return _MMD_LIB.has_metadata(source.encode('utf-8'), ext)
777683
def _add_command(self, name, **parameters):
        
        command = self._create_command(name, **parameters)
        self._commands.append(command)

        return command