(self)
return self.STATUS_ERROR
Command parsing and selection
Command parsing and selection
Command parsing and selection
def execute(self):
        """Command parsing and selection"""
        self._prepare_exec()
        cmds = {
            "search": self.cli.do_search, "help": self.cli.do_help,
            "images": self.cli.do_images, "pull": self.cli.do_pull,
            "create": self.cli.do_create, "ps": self.cli.do_ps,
            "run": self.cli.do_run, "version": self.cli.do_version,
            "rmi": self.cli.do_rmi, "mkrepo": self.cli.do_mkrepo,
            "import": self.cli.do_import, "load": self.cli.do_load,
            "export": self.cli.do_export, "clone": self.cli.do_clone,
            "protect": self.cli.do_protect, "rm": self.cli.do_rm,
            "name": self.cli.do_name, "rmname": self.cli.do_rmname,
            "verify": self.cli.do_verify, "logout": self.cli.do_logout,
            "unprotect": self.cli.do_unprotect, "rename": self.cli.do_rename,
            "showconf": self.cli.do_showconf, "save": self.cli.do_save,
            "inspect": self.cli.do_inspect, "login": self.cli.do_login,
            "setup": self.cli.do_setup, "install": self.cli.do_install,
        }

        if ((len(self.argv) == 1) or
                self.cmdp.get("-h", "GEN_OPT") or
                self.cmdp.get("--help", "GEN_OPT")):
            return self.cli.do_help(self.cmdp)

        if (self.cmdp.get("-V", "GEN_OPT") or
                self.cmdp.get("--version", "GEN_OPT")):
            return self.cli.do_version(self.cmdp)

        command = self.cmdp.get("", "CMD")
        if command in cmds:
            if self.cmdp.get("--help", "CMD_OPT"):
                Msg().out(cmds[command].__doc__)
                return self.STATUS_OK
            if command in ["version", "showconf"]:
                return cmds[command](self.cmdp)
            if command != "install":
                self.cli.do_install(None)
            exit_status = cmds[command](self.cmdp)  # executes command
            if self.cmdp.missing_options():
                Msg().err("Error: syntax error at: %s" %
                          " ".join(self.cmdp.missing_options()))
                return self.STATUS_ERROR

            return exit_status

        Msg().err("Error: invalid command:", command, "\n")
        return self.STATUS_ERROR
def execute ( self ) : self . _prepare_exec ( ) cmds = { "search" : self . cli . do_search , "help" : self . cli . do_help , "images" : self . cli . do_images , "pull" : self . cli . do_pull , "create" : self . cli . do_create , "ps" : self . cli . do_ps , "run" : self . cli . do_run , "version" : self . cli . do_version , "rmi" : self . cli . do_rmi , "mkrepo" : self . cli . do_mkrepo , "import" : self . cli . do_import , "load" : self . cli . do_load , "export" : self . cli . do_export , "clone" : self . cli . do_clone , "protect" : self . cli . do_protect , "rm" : self . cli . do_rm , "name" : self . cli . do_name , "rmname" : self . cli . do_rmname , "verify" : self . cli . do_verify , "logout" : self . cli . do_logout , "unprotect" : self . cli . do_unprotect , "rename" : self . cli . do_rename , "showconf" : self . cli . do_showconf , "save" : self . cli . do_save , "inspect" : self . cli . do_inspect , "login" : self . cli . do_login , "setup" : self . cli . do_setup , "install" : self . cli . do_install , } if ( ( len ( self . argv ) == 1 ) or self . cmdp . get ( "-h" , "GEN_OPT" ) or self . cmdp . get ( "--help" , "GEN_OPT" ) ) : return self . cli . do_help ( self . cmdp ) if ( self . cmdp . get ( "-V" , "GEN_OPT" ) or self . cmdp . get ( "--version" , "GEN_OPT" ) ) : return self . cli . do_version ( self . cmdp ) command = self . cmdp . get ( "" , "CMD" ) if command in cmds : if self . cmdp . get ( "--help" , "CMD_OPT" ) : Msg ( ) . out ( cmds [ command ] . __doc__ ) return self . STATUS_OK if command in [ "version" , "showconf" ] : return cmds [ command ] ( self . cmdp ) if command != "install" : self . cli . do_install ( None ) exit_status = cmds [ command ] ( self . cmdp ) # executes command if self . cmdp . missing_options ( ) : Msg ( ) . err ( "Error: syntax error at: %s" % " " . join ( self . cmdp . missing_options ( ) ) ) return self . STATUS_ERROR return exit_status Msg ( ) . err ( "Error: invalid command:" , command , "\n" ) return self . STATUS_ERROR