(self, parser, args)
return args
Parse the command-line options for a single command.
        'parser' must be a FancyGetopt instance; 'args' must be the list
        of arguments, starting with the current command (whose options
        we are about to parse).  Returns a new version of 'args' with
        the next command at the front of the list; will be the empty
        list if there are no more commands on the command line.  Returns
        None if the user asked for help on this command.
Parse the command-line options for a single command.
        'parser' must be a FancyGetopt instance; 'args' must be the list
        of arguments, starting with the current command (whose options
        we are about to parse).  Returns a new version of 'args' with
        the next command at the front of the list; will be the empty
        list if there are no more commands on the command line.  Returns
        None if the user asked for help on this command.
Parse the command - line options for a single command . parser must be a FancyGetopt instance ; args must be the list of arguments starting with the current command ( whose options we are about to parse ) . Returns a new version of args with the next command at the front of the list ; will be the empty list if there are no more commands on the command line . Returns None if the user asked for help on this command .
def _parse_command_opts(self, parser, args):
        """Parse the command-line options for a single command.
        'parser' must be a FancyGetopt instance; 'args' must be the list
        of arguments, starting with the current command (whose options
        we are about to parse).  Returns a new version of 'args' with
        the next command at the front of the list; will be the empty
        list if there are no more commands on the command line.  Returns
        None if the user asked for help on this command.
        """
        # late import because of mutual dependence between these modules
        from distutils.cmd import Command

        # Pull the current command from the head of the command line
        command = args[0]
        if not command_re.match(command):
            raise SystemExit("invalid command name '%s'" % command)
        self.commands.append(command)

        # Dig up the command class that implements this command, so we
        # 1) know that it's a valid command, and 2) know which options
        # it takes.
        try:
            cmd_class = self.get_command_class(command)
        except DistutilsModuleError as msg:
            raise DistutilsArgError(msg)

        # Require that the command class be derived from Command -- want
        # to be sure that the basic "command" interface is implemented.
        if not issubclass(cmd_class, Command):
            raise DistutilsClassError(
                "command class %s must subclass Command" % cmd_class)

        # Also make sure that the command object provides a list of its
        # known options.
        if not (hasattr(cmd_class, 'user_options') and
                isinstance(cmd_class.user_options, list)):
            msg = ("command class %s must provide "
                "'user_options' attribute (a list of tuples)")
            raise DistutilsClassError(msg % cmd_class)

        # If the command class has a list of negative alias options,
        # merge it in with the global negative aliases.
        negative_opt = self.negative_opt
        if hasattr(cmd_class, 'negative_opt'):
            negative_opt = negative_opt.copy()
            negative_opt.update(cmd_class.negative_opt)

        # Check for help_options in command class.  They have a different
        # format (tuple of four) so we need to preprocess them here.
        if (hasattr(cmd_class, 'help_options') and
                isinstance(cmd_class.help_options, list)):
            help_options = fix_help_options(cmd_class.help_options)
        else:
            help_options = []

        # All commands support the global options too, just by adding
        # in 'global_options'.
        parser.set_option_table(self.global_options +
                                cmd_class.user_options +
                                help_options)
        parser.set_negative_aliases(negative_opt)
        (args, opts) = parser.getopt(args[1:])
        if hasattr(opts, 'help') and opts.help:
            self._show_help(parser, display_options=0, commands=[cmd_class])
            return

        if (hasattr(cmd_class, 'help_options') and
                isinstance(cmd_class.help_options, list)):
            help_option_found=0
            for (help_option, short, desc, func) in cmd_class.help_options:
                if hasattr(opts, parser.get_attr_name(help_option)):
                    help_option_found=1
                    if callable(func):
                        func()
                    else:
                        raise DistutilsClassError(
                            "invalid help function %r for help option '%s': "
                            "must be a callable object (function, etc.)"
                            % (func, help_option))

            if help_option_found:
                return

        # Put the options from the command-line into their official
        # holding pen, the 'command_options' dictionary.
        opt_dict = self.get_option_dict(command)
        for (name, value) in vars(opts).items():
            opt_dict[name] = ("command line", value)

        return args
def _parse_command_opts ( self , parser , args ) : # late import because of mutual dependence between these modules from distutils . cmd import Command # Pull the current command from the head of the command line command = args [ 0 ] if not command_re . match ( command ) : raise SystemExit ( "invalid command name '%s'" % command ) self . commands . append ( command ) # Dig up the command class that implements this command, so we # 1) know that it's a valid command, and 2) know which options # it takes. try : cmd_class = self . get_command_class ( command ) except DistutilsModuleError as msg : raise DistutilsArgError ( msg ) # Require that the command class be derived from Command -- want # to be sure that the basic "command" interface is implemented. if not issubclass ( cmd_class , Command ) : raise DistutilsClassError ( "command class %s must subclass Command" % cmd_class ) # Also make sure that the command object provides a list of its # known options. if not ( hasattr ( cmd_class , 'user_options' ) and isinstance ( cmd_class . user_options , list ) ) : msg = ( "command class %s must provide " "'user_options' attribute (a list of tuples)" ) raise DistutilsClassError ( msg % cmd_class ) # If the command class has a list of negative alias options, # merge it in with the global negative aliases. negative_opt = self . negative_opt if hasattr ( cmd_class , 'negative_opt' ) : negative_opt = negative_opt . copy ( ) negative_opt . update ( cmd_class . negative_opt ) # Check for help_options in command class.  They have a different # format (tuple of four) so we need to preprocess them here. if ( hasattr ( cmd_class , 'help_options' ) and isinstance ( cmd_class . help_options , list ) ) : help_options = fix_help_options ( cmd_class . help_options ) else : help_options = [ ] # All commands support the global options too, just by adding # in 'global_options'. parser . set_option_table ( self . global_options + cmd_class . user_options + help_options ) parser . set_negative_aliases ( negative_opt ) ( args , opts ) = parser . getopt ( args [ 1 : ] ) if hasattr ( opts , 'help' ) and opts . help : self . _show_help ( parser , display_options = 0 , commands = [ cmd_class ] ) return if ( hasattr ( cmd_class , 'help_options' ) and isinstance ( cmd_class . help_options , list ) ) : help_option_found = 0 for ( help_option , short , desc , func ) in cmd_class . help_options : if hasattr ( opts , parser . get_attr_name ( help_option ) ) : help_option_found = 1 if callable ( func ) : func ( ) else : raise DistutilsClassError ( "invalid help function %r for help option '%s': " "must be a callable object (function, etc.)" % ( func , help_option ) ) if help_option_found : return # Put the options from the command-line into their official # holding pen, the 'command_options' dictionary. opt_dict = self . get_option_dict ( command ) for ( name , value ) in vars ( opts ) . items ( ) : opt_dict [ name ] = ( "command line" , value ) return args