This commit is contained in:
2025-05-15 00:46:57 +02:00
parent 30c71cb449
commit b2b27b2c3d
18 changed files with 622 additions and 234 deletions

View File

@@ -12,20 +12,18 @@ import (
type (
ListCmd struct {
name string
}
)
func (*ListCmd) Name() string { return "list" }
func (*ListCmd) Synopsis() string { return "list all game registered" }
func (*ListCmd) Usage() string {
return `add:
return `list:
List all game registered
`
}
func (p *ListCmd) SetFlags(f *flag.FlagSet) {
f.StringVar(&p.name, "name", "", "Override the name of the game")
}
func (p *ListCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {

View File

@@ -2,7 +2,6 @@ package sync
import (
"cloudsave/pkg/remote"
"cloudsave/pkg/sync/ssh"
"context"
"flag"
"fmt"
@@ -28,15 +27,15 @@ func (p *SyncCmd) SetFlags(f *flag.FlagSet) {
}
func (p *SyncCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
remotes, err := remote.All()
_, 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)
}
/*for _, remote := range remotes {
}*/
return subcommands.ExitSuccess
}

View File

@@ -0,0 +1,38 @@
package version
import (
"cloudsave/pkg/constants"
"context"
"flag"
"fmt"
"runtime"
"strconv"
"github.com/google/subcommands"
)
type (
VersionCmd struct {
}
)
func (*VersionCmd) Name() string { return "version" }
func (*VersionCmd) Synopsis() string { return "show version and system information" }
func (*VersionCmd) Usage() string {
return `add:
Show version and system information
`
}
func (p *VersionCmd) SetFlags(f *flag.FlagSet) {
}
func (p *VersionCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}) subcommands.ExitStatus {
fmt.Println("Client: CloudSave cli")
fmt.Println(" Version: " + constants.Version)
fmt.Println(" API version: " + strconv.Itoa(constants.ApiVersion))
fmt.Println(" Go version: " + runtime.Version())
fmt.Println(" OS/Arch: " + runtime.GOOS + "/" + runtime.GOARCH)
return subcommands.ExitSuccess
}

View File

@@ -7,6 +7,7 @@ import (
"cloudsave/cmd/cli/commands/remove"
"cloudsave/cmd/cli/commands/run"
"cloudsave/cmd/cli/commands/sync"
"cloudsave/cmd/cli/commands/version"
"context"
"flag"
"os"
@@ -18,6 +19,7 @@ func main() {
subcommands.Register(subcommands.HelpCommand(), "help")
subcommands.Register(subcommands.FlagsCommand(), "help")
subcommands.Register(subcommands.CommandsCommand(), "help")
subcommands.Register(&version.VersionCmd{}, "help")
subcommands.Register(&add.AddCmd{}, "management")
subcommands.Register(&run.RunCmd{}, "management")