github.com/KusionStack/kpm@v0.8.4-0.20240326033734-dc72298a30e5/pkg/cmd/cmd_logout.go (about) 1 // Copyright 2023 The KCL Authors. All rights reserved. 2 // Deprecated: The entire contents of this file will be deprecated. 3 // Please use the kcl cli - https://github.com/kcl-lang/cli. 4 5 package cmd 6 7 import ( 8 "fmt" 9 10 "github.com/urfave/cli/v2" 11 "kcl-lang.io/kpm/pkg/client" 12 "kcl-lang.io/kpm/pkg/reporter" 13 ) 14 15 // NewLogoutCmd new a Command for `kpm logout`. 16 func NewLogoutCmd(kpmcli *client.KpmClient) *cli.Command { 17 return &cli.Command{ 18 Hidden: false, 19 Name: "logout", 20 Usage: "logout from a registry", 21 Action: func(c *cli.Context) error { 22 if c.NArg() == 0 { 23 return reporter.NewErrorEvent( 24 reporter.InvalidCmd, 25 fmt.Errorf("registry must be specified"), 26 ) 27 } 28 err := kpmcli.LogoutOci(c.Args().First()) 29 if err != nil { 30 return err 31 } 32 reporter.ReportMsgTo("Logout Succeeded", kpmcli.GetLogWriter()) 33 return nil 34 }, 35 } 36 }