implement applu
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package apply
|
||||
|
||||
import (
|
||||
"cloudsave/pkg/data"
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
@@ -11,13 +12,14 @@ import (
|
||||
|
||||
type (
|
||||
ListCmd struct {
|
||||
Service *data.Service
|
||||
}
|
||||
)
|
||||
|
||||
func (*ListCmd) Name() string { return "apply" }
|
||||
func (*ListCmd) Synopsis() string { return "apply a backup" }
|
||||
func (*ListCmd) Usage() string {
|
||||
return `Usage: cloudsave apply <GAME_ID> <BACKUP_ID>
|
||||
return `Usage: cloudsave apply <GAME_ID> [BACKUP_ID]
|
||||
|
||||
Apply a backup
|
||||
`
|
||||
@@ -27,15 +29,26 @@ func (p *ListCmd) SetFlags(f *flag.FlagSet) {
|
||||
}
|
||||
|
||||
func (p *ListCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
|
||||
if f.NArg() != 2 {
|
||||
if f.NArg() < 1 {
|
||||
fmt.Fprintln(os.Stderr, "error: missing game ID and/or backup uuid")
|
||||
return subcommands.ExitUsageError
|
||||
}
|
||||
|
||||
//gameID := f.Arg(0)
|
||||
//uuid := f.Arg(1)
|
||||
gameID := f.Arg(0)
|
||||
uuid := f.Arg(1)
|
||||
|
||||
panic("not implemented")
|
||||
if len(uuid) == 0 {
|
||||
if err := p.Service.ApplyCurrent(gameID); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: failed to apply: %s", err)
|
||||
return subcommands.ExitFailure
|
||||
}
|
||||
return subcommands.ExitSuccess
|
||||
}
|
||||
|
||||
if err := p.Service.ApplyBackup(gameID, uuid); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error: failed to apply: %s", err)
|
||||
return subcommands.ExitFailure
|
||||
}
|
||||
|
||||
return subcommands.ExitSuccess
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"cloudsave/cmd/cli/commands/add"
|
||||
"cloudsave/cmd/cli/commands/apply"
|
||||
"cloudsave/cmd/cli/commands/list"
|
||||
"cloudsave/cmd/cli/commands/pull"
|
||||
"cloudsave/cmd/cli/commands/remote"
|
||||
@@ -48,6 +49,8 @@ func main() {
|
||||
subcommands.Register(&list.ListCmd{Service: s}, "management")
|
||||
subcommands.Register(&remove.RemoveCmd{Service: s}, "management")
|
||||
|
||||
subcommands.Register(&apply.ListCmd{Service: s}, "restore")
|
||||
|
||||
subcommands.Register(&remote.RemoteCmd{Service: s}, "remote")
|
||||
subcommands.Register(&sync.SyncCmd{Service: s}, "remote")
|
||||
subcommands.Register(&pull.PullCmd{Service: s}, "remote")
|
||||
|
||||
Reference in New Issue
Block a user