Ejemplo n.º 1
0
    def parse(self, input_args):
        parsed_args = self.parser.parse_args(input_args)

        args, kwargs = [], {}
        for arg, arg_name in zip(self.args, self.arg_names):
            if arg.required:
                args.append(getattr(parsed_args, arg_name))
            elif hasattr(parsed_args, arg_name):
                kwargs[arg_name] = getattr(parsed_args, arg_name)

        return args, kwargs
Ejemplo n.º 2
0
 def parse(self, args):
     parsed_args = self.parser.parse_args(args)
     args, kwargs = [], {}
     position = 0
     for arg_name in self.arg_names:
         arg = self.args[position]
         if arg.required:
             args.append(getattr(parsed_args, arg_name))
         elif hasattr(parsed_args, arg_name):
             kwargs[arg_name] = getattr(parsed_args, arg_name)
         position = position + 1
     return self.puts(self.run(*args, **kwargs))