This commit is contained in:
43
cmd/cli/commands/logout/logout.go
Normal file
43
cmd/cli/commands/logout/logout.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package logout
|
||||
|
||||
import (
|
||||
"cloudsave/cmd/cli/tools/prompt/credentials"
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/google/subcommands"
|
||||
)
|
||||
|
||||
type (
|
||||
LogoutCmd struct {
|
||||
}
|
||||
)
|
||||
|
||||
func (*LogoutCmd) Name() string { return "logout" }
|
||||
func (*LogoutCmd) Synopsis() string { return "logout from a server" }
|
||||
func (*LogoutCmd) Usage() string {
|
||||
return `Usage: cloudsave logout <SERVER_HOSTNAME>
|
||||
|
||||
Options:
|
||||
`
|
||||
}
|
||||
|
||||
func (p *LogoutCmd) SetFlags(f *flag.FlagSet) {
|
||||
}
|
||||
|
||||
func (p *LogoutCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
|
||||
if f.NArg() != 1 {
|
||||
fmt.Fprintf(os.Stderr, "error: this command take 1 argument")
|
||||
return subcommands.ExitUsageError
|
||||
}
|
||||
|
||||
if err := credentials.Logout(f.Arg(0)); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: failed to logout: %s", err)
|
||||
return subcommands.ExitFailure
|
||||
}
|
||||
|
||||
fmt.Println("bye!")
|
||||
return subcommands.ExitSuccess
|
||||
}
|
||||
Reference in New Issue
Block a user