Some checks failed
CloudSave/pipeline/head Something is wrong with the build of this commit
44 lines
889 B
Go
44 lines
889 B
Go
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
|
|
}
|