first alpha version cli
This commit is contained in:
40
cmd/cli/commands/remove/remove.go
Normal file
40
cmd/cli/commands/remove/remove.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package remove
|
||||
|
||||
import (
|
||||
"cloudsave/pkg/game"
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/google/subcommands"
|
||||
)
|
||||
|
||||
type (
|
||||
RemoveCmd struct{}
|
||||
)
|
||||
|
||||
func (*RemoveCmd) Name() string { return "remove" }
|
||||
func (*RemoveCmd) Synopsis() string { return "unregister a game" }
|
||||
func (*RemoveCmd) Usage() string {
|
||||
return `remove:
|
||||
Unregister a game
|
||||
`
|
||||
}
|
||||
|
||||
func (p *RemoveCmd) SetFlags(f *flag.FlagSet) {
|
||||
}
|
||||
|
||||
func (p *RemoveCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
|
||||
if f.NArg() != 1 {
|
||||
fmt.Fprintln(os.Stderr, "error: the command is expecting for 1 argument")
|
||||
return subcommands.ExitUsageError
|
||||
}
|
||||
|
||||
err := game.Remove(f.Arg(0))
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "error: failed to unregister the game:", err)
|
||||
return subcommands.ExitFailure
|
||||
}
|
||||
return subcommands.ExitSuccess
|
||||
}
|
||||
Reference in New Issue
Block a user