Exemplo n.º 1
0
 def _build_argument_table(self):
     argument_table = OrderedDict()
     cli_data = self._get_cli_data()
     cli_arguments = cli_data.get('options', None)
     for option in cli_arguments:
         option_params = copy_kwargs(cli_arguments[option])
         # Special case the 'choices' param.  Allows choices
         # to reference a variable from the session.
         if 'choices' in option_params:
             choices = option_params['choices']
             if not isinstance(choices, list):
                 # Assume it's a reference like
                 # "{provider}/_foo", so first resolve
                 # the provider.
                 provider = self.session.get_config_variable('provider')
                 # The grab the var from the session
                 choices_path = choices.format(provider=provider)
                 choices = list(self.session.get_data(choices_path))
             option_params['choices'] = choices
         cli_argument = self._create_cli_argument(option, option_params)
         cli_argument.add_to_arg_table(argument_table)
     # Then the final step is to send out an event so handlers
     # can add extra arguments or modify existing arguments.
     self.session.emit('building-top-level-params',
                       argument_table=argument_table)
     return argument_table
Exemplo n.º 2
0
 def _build_argument_table(self):
     argument_table = OrderedDict()
     cli_data = self._get_cli_data()
     cli_arguments = cli_data.get('options', None)
     for option in cli_arguments:
         option_params = copy_kwargs(cli_arguments[option])
         # Special case the 'choices' param.  Allows choices
         # to reference a variable from the session.
         if 'choices' in option_params:
             choices = option_params['choices']
             if not isinstance(choices, list):
                 # Assume it's a reference like
                 # "{provider}/_regions", so first resolve
                 # the provider.
                 provider = self.session.get_variable('provider')
                 # The grab the var from the session
                 choices_path = choices.format(provider=provider)
                 choices = list(self.session.get_data(choices_path))
             option_params['choices'] = choices
         argument_object = self._create_argument_object(option,
                                                        option_params)
         argument_object.add_to_arg_table(argument_table)
     # Then the final step is to send out an event so handlers
     # can add extra arguments or modify existing arguments.
     self.session.emit('building-top-level-params',
                       argument_table=argument_table)
     return argument_table
Exemplo n.º 3
0
 def create_main_parser(self):
     """
     Create the main parser to handle the global arguments.
     """
     self.cli_data = self.session.get_data('cli')
     description = self.cli_data['description']
     self.parser = argparse.ArgumentParser(formatter_class=self.Formatter,
                                           description=description,
                                           add_help=False,
                                           conflict_handler='resolve')
     for option_name in self.cli_data['options']:
         option_data = copy_kwargs(self.cli_data['options'][option_name])
         if 'choices' in option_data:
             choices = option_data['choices']
             if not isinstance(choices, list):
                 provider = self.session.get_variable('provider')
                 choices_path = choices.format(provider=provider)
                 choices = self.session.get_data(choices_path)
             if isinstance(choices, dict):
                 choices = list(choices.keys())
             option_data['help'] = self.create_choice_help(choices)
             option_data['choices'] = choices + ['help']
         self.parser.add_argument(option_name, **option_data)
     self.parser.add_argument('--version', action="version",
                              version=self.session.user_agent())
 def _build_argument_table(self):
     argument_table = OrderedDict()
     cli_data = self._get_cli_data()
     cli_arguments = cli_data.get('options', None)
     for option in cli_arguments:
         option_params = copy_kwargs(cli_arguments[option])
         cli_argument = self._create_cli_argument(option, option_params)
         cli_argument.add_to_arg_table(argument_table)
     # Then the final step is to send out an event so handlers
     # can add extra arguments or modify existing arguments.
     self.session.emit('building-top-level-params',
                       argument_table=argument_table)
     return argument_table
Exemplo n.º 5
0
 def _build_argument_table(self):
     argument_table = OrderedDict()
     cli_data = self._get_cli_data()
     cli_arguments = cli_data.get('options', None)
     for option in cli_arguments:
         option_params = copy_kwargs(cli_arguments[option])
         cli_argument = self._create_cli_argument(option, option_params)
         cli_argument.add_to_arg_table(argument_table)
     # Then the final step is to send out an event so handlers
     # can add extra arguments or modify existing arguments.
     self.session.emit('building-top-level-params',
                       argument_table=argument_table)
     return argument_table
Exemplo n.º 6
0
def build_argument_table(cli_data):
    """
    Create an argument table, which contains all of the arguments
    that are available to the aws-cli. This is used in the Checker
    class to ensure correct usage of global aws-cli arguments.
    """
    log.debug('Building command table')
    argument_table = OrderedDict()
    cli_arguments = cli_data.get('options', None)
    for option in cli_arguments:
        option_params = copy_kwargs(cli_arguments[option])
        cli_argument = _create_cli_argument(option, option_params)
        cli_argument.add_to_arg_table(argument_table)
    return argument_table
Exemplo n.º 7
0
 def build(self):
     for option_name in self.cli_data['options']:
         option_data = copy_kwargs(self.cli_data['options'][option_name])
         if 'choices' in option_data:
             choices = option_data['choices']
             if not isinstance(choices, list):
                 provider = self.session.get_variable('provider')
                 choices_path = choices.format(provider=provider)
                 choices = self.session.get_data(choices_path)
             if isinstance(choices, dict):
                 choices = list(choices.keys())
             option_data['help'] = self._create_choice_help(choices)
             option_data['choices'] = choices + ['help']
         self.add_argument(option_name, **option_data)
     self.add_argument('--version', action="version",
                       version=self.session.user_agent())
Exemplo n.º 8
0
 def build(self):
     for option_name in self.cli_data['options']:
         option_data = copy_kwargs(self.cli_data['options'][option_name])
         if 'choices' in option_data:
             choices = option_data['choices']
             if not isinstance(choices, list):
                 provider = self.session.get_variable('provider')
                 choices_path = choices.format(provider=provider)
                 choices = self.session.get_data(choices_path)
             if isinstance(choices, dict):
                 choices = list(choices.keys())
             option_data['help'] = self._create_choice_help(choices)
             option_data['choices'] = choices + ['help']
         self.add_argument(option_name, **option_data)
     self.add_argument('--version',
                       action="version",
                       version=self.session.user_agent())