Files
cloudsave/cmd/cli/commands/sync/sync.go
2025-05-11 02:32:33 +02:00

43 lines
785 B
Go

package sync
import (
"cloudsave/pkg/remote"
"cloudsave/pkg/sync/ssh"
"context"
"flag"
"fmt"
"os"
"github.com/google/subcommands"
)
type (
SyncCmd struct {
}
)
func (*SyncCmd) Name() string { return "sync" }
func (*SyncCmd) Synopsis() string { return "list all game registered" }
func (*SyncCmd) Usage() string {
return `add:
List all game registered
`
}
func (p *SyncCmd) SetFlags(f *flag.FlagSet) {
}
func (p *SyncCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
remotes, err := remote.All()
if err != nil {
fmt.Fprintln(os.Stderr, "error: failed to load datastore:", err)
return subcommands.ExitFailure
}
for _, remote := range remotes {
ssh.SFTPSyncer{}.Sync(remote)
}
return subcommands.ExitSuccess
}