wip
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user