From 179fd44985c37dab4ca35f572a6b3b2dd3977c96 Mon Sep 17 00:00:00 2001 From: vouv Date: Sat, 2 Jan 2021 18:17:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=BA=E9=94=99=E4=B8=8D=E6=89=93=E5=8D=B0Us?= =?UTF-8?q?age?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/srun/cli.go | 27 +++++++++++++++++++++++++++ cmd/srun/main.go | 12 ++++++------ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/cmd/srun/cli.go b/cmd/srun/cli.go index 6af9915..e069728 100644 --- a/cmd/srun/cli.go +++ b/cmd/srun/cli.go @@ -15,6 +15,13 @@ import ( "github.com/vouv/srun/store" ) +func Login(cmd *cobra.Command, args []string) { + err := LoginE(cmd, args) + if err != nil { + log.Error(err) + } +} + func LoginE(cmd *cobra.Command, args []string) error { account, err := store.ReadAccount() if err != nil { @@ -30,6 +37,13 @@ func LoginE(cmd *cobra.Command, args []string) error { return store.WriteAccount(account) } +func Logout(cmd *cobra.Command, args []string) { + err := LogoutE(cmd, args) + if err != nil { + log.Error(err) + } +} + func LogoutE(cmd *cobra.Command, args []string) error { var err error account, err := store.ReadAccount() @@ -44,6 +58,13 @@ func LogoutE(cmd *cobra.Command, args []string) error { return store.WriteAccount(account) } +func Info(cmd *cobra.Command, args []string) { + err := InfoE(cmd, args) + if err != nil { + log.Error(err) + } +} + func InfoE(cmd *cobra.Command, args []string) error { info, err := core.Info() if err != nil { @@ -53,6 +74,12 @@ func InfoE(cmd *cobra.Command, args []string) error { return nil } +func Config(cmd *cobra.Command, args []string) { + err := ConfigE(cmd, args) + if err != nil { + log.Error(err) + } +} func ConfigE(cmd *cobra.Command, args []string) error { in := os.Stdin diff --git a/cmd/srun/main.go b/cmd/srun/main.go index c3e1a36..068ab06 100755 --- a/cmd/srun/main.go +++ b/cmd/srun/main.go @@ -7,30 +7,30 @@ import ( "github.com/spf13/cobra" ) -const Version = "v1.1.4" +const Version = "v1.1.5" var loginCmd = &cobra.Command{ Use: "login", Short: "Login srun", - RunE: LoginE, + Run: Login, } var logoutCmd = &cobra.Command{ Use: "logout", Short: "Logout srun", - RunE: LogoutE, + Run: Logout, } var infoCmd = &cobra.Command{ Use: "info", Short: "Get srun info", - RunE: InfoE, + Run: Info, } var configCmd = &cobra.Command{ Use: "config", Short: "Config srun", - RunE: ConfigE, + Run: Config, } var rootCmd = &cobra.Command{ @@ -63,7 +63,7 @@ func main() { log.SetOutput(os.Stdout) log.SetLevel(log.InfoLevel) log.SetFormatter(&log.TextFormatter{ - //DisableTimestamp: true, + // DisableTimestamp: true, TimestampFormat: "2006-01-02 15:04:05", FullTimestamp: true, })