serverless arch

This commit is contained in:
2025-05-11 02:32:33 +02:00
parent 15b1efcc48
commit 30c71cb449
8 changed files with 291 additions and 27 deletions

View File

@@ -0,0 +1,42 @@
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
}

View File

@@ -6,6 +6,7 @@ import (
"cloudsave/cmd/cli/commands/remote"
"cloudsave/cmd/cli/commands/remove"
"cloudsave/cmd/cli/commands/run"
"cloudsave/cmd/cli/commands/sync"
"context"
"flag"
"os"
@@ -24,6 +25,7 @@ func main() {
subcommands.Register(&remove.RemoveCmd{}, "management")
subcommands.Register(&remote.RemoteCmd{}, "remote")
subcommands.Register(&sync.SyncCmd{}, "remote")
flag.Parse()
ctx := context.Background()