implement applu

This commit is contained in:
2025-08-17 00:30:02 +02:00
parent aa29fae900
commit 851ff89886
4 changed files with 61 additions and 6 deletions

View File

@@ -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
}