Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var LoginCmd = &cobra.Command{ Use: "login", Short: "commond for login", Run: func(cmd *cobra.Command, args []string) { err := errors.New("") gwHandler := handler.NewGWHandler() gwHandler.SetLogger(logger) err = gwHandler.Login(username, password) if err != nil { file, line := utils.GetErrorLocation() logger.Debug(fmt.Sprintf("Error in file %s, line %d: %v", file, line, err)) fmt.Println(err) return } ipgwHandler := handler.NewIPGWHandler() ipgwHandler.SetClient(gwHandler.GetClient()) ipgwHandler.SetLogger(logger) msg, err := ipgwHandler.Login() if err != nil { file, line := utils.GetErrorLocation() logger.Debug(fmt.Sprintf("Error in file %s, line %d: %v", file, line, err)) fmt.Println(err) return } fmt.Println(msg) }, }
View Source
var LogoutCmd = &cobra.Command{ Use: "logout", Short: "commond for logout", Run: func(cmd *cobra.Command, args []string) { err := errors.New("") ipgwHandler := handler.NewIPGWHandler() ipgwHandler.SetLogger(logger) err = ipgwHandler.Logout() if err != nil { file, line := utils.GetErrorLocation() logger.Debug(fmt.Sprintf("Error in file %s, line %d: %v", file, line, err)) fmt.Println(err) return } fmt.Println("logout success") }, }
View Source
var RootCmd = &cobra.Command{ Use: "NEU_IPGW", Short: "NEU_IPGW is a command line interface for NEU internet connect", PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) { if cmd.Name() == VersionCmd.Name() { return nil } switch log_level { case "error": logger.SetLevel(logrus.ErrorLevel) break case "warn": logger.SetLevel(logrus.WarnLevel) break case "info": logger.SetLevel(logrus.InfoLevel) break case "debug": logger.SetLevel(logrus.DebugLevel) break case "trace": logger.SetLevel(logrus.TraceLevel) break default: logger.SetLevel(logrus.InfoLevel) } if log_format == "json" { logger.SetFormatter(&logrus.JSONFormatter{}) } logger.SetOutput(os.Stdout) return nil }, }
RootCmd is the root command for NEU_IPGW. config log level and log format
View Source
var VersionCmd = &cobra.Command{ Use: "version", Short: "show the version info", Run: func(cmd *cobra.Command, args []string) { if verbose { values, _ := json.MarshalIndent(struct { NEU_IPGW string `json:"neu_ipgw"` Build string `json:"build"` Repo string `json:"repo"` }{ NEU_IPGW: version.Version, Build: version.Build, Repo: version.Repo, }, "", " ") fmt.Println(string(values)) } else { fmt.Println(version.Version) } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.