Example #1
0
    def start(self, args=None):
        """Begin command line program

        By default will use the command line arguments passed when Python was
        initially started. New arguments can be passed through the args
        parameter.
        """
        commands = [[]]
        args = args if args is not None else sys.argv[1:]
        if len(args) > 0:
            commands = [list(group) for key, group in itertools.groupby(args, lambda x: x == self._cmd_delim) if not key]
        options = []
        for command in commands:
            opts = self._parser.parse_args(command)
            options.append(opts)
        context.clear()
        context.opts_next = tuple(options)
        for count, opts in enumerate(options):
            context.opts_next = context.opts_next[1:]
            context.opts_current = opts
            cmdline.apply_options(self.__wrapped__, opts,
                    run_main=(count==0), sub_group=self._group,
                    collector=self._collector)
            context.opts_previous += (opts,)
        context.opts_current = None
        return context.last_return
Example #2
0
    def start(self, args=None):
        """Begin command line program

        By default will use the command line arguments passed when Python was
        initially started. New arguments can be passed through the args
        parameter.
        """
        commands = [[]]
        args = args if args is not None else sys.argv[1:]
        if len(args) > 0:
            commands = [
                list(group) for key, group in itertools.groupby(
                    args, lambda x: x == self._cmd_delim) if not key
            ]
        options = []
        for command in commands:
            opts = self._parser.parse_args(command)
            options.append(opts)
        context.clear()
        context.opts_next = tuple(options)
        for count, opts in enumerate(options):
            context.opts_next = context.opts_next[1:]
            context.opts_current = opts
            cmdline.apply_options(self.__wrapped__,
                                  opts,
                                  run_main=(count == 0),
                                  sub_group=self._group,
                                  collector=self._collector)
            context.opts_previous += (opts, )
        context.opts_current = None
        return context.last_return
Example #3
0
 def setUp(self):
     context.clear()
Example #4
0
 def setUp(self):
     context.clear()