This commit is contained in:
2025-08-09 22:19:57 +02:00
parent 13adb26fba
commit 810c5ac627
13 changed files with 605 additions and 790 deletions

View File

@@ -9,27 +9,48 @@ import (
"cloudsave/cmd/cli/commands/run"
"cloudsave/cmd/cli/commands/sync"
"cloudsave/cmd/cli/commands/version"
"cloudsave/pkg/data"
"cloudsave/pkg/repository"
"context"
"flag"
"os"
"path/filepath"
"github.com/google/subcommands"
)
func main() {
roaming, err := os.UserConfigDir()
if err != nil {
panic("failed to get user config path: " + err.Error())
}
datastorepath := filepath.Join(roaming, "cloudsave", "data")
err = os.MkdirAll(datastorepath, 0740)
if err != nil {
panic("cannot make the datastore:" + err.Error())
}
repo, err := repository.NewLazyRepository(datastorepath)
if err != nil {
panic("cannot make the datastore:" + err.Error())
}
s := data.NewService(repo)
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")
subcommands.Register(&list.ListCmd{}, "management")
subcommands.Register(&remove.RemoveCmd{}, "management")
subcommands.Register(&add.AddCmd{Service: s}, "management")
subcommands.Register(&run.RunCmd{Service: s}, "management")
subcommands.Register(&list.ListCmd{Service: s}, "management")
subcommands.Register(&remove.RemoveCmd{Service: s}, "management")
subcommands.Register(&remote.RemoteCmd{}, "remote")
subcommands.Register(&sync.SyncCmd{}, "remote")
subcommands.Register(&pull.PullCmd{}, "remote")
subcommands.Register(&remote.RemoteCmd{Service: s}, "remote")
subcommands.Register(&sync.SyncCmd{Service: s}, "remote")
subcommands.Register(&pull.PullCmd{Service: s}, "remote")
flag.Parse()
ctx := context.Background()