Some checks failed
CloudSave/pipeline/head There was a failure building this commit
69 lines
2.0 KiB
Go
69 lines
2.0 KiB
Go
package main
|
|
|
|
import (
|
|
"cloudsave/cmd/cli/commands/add"
|
|
"cloudsave/cmd/cli/commands/apply"
|
|
"cloudsave/cmd/cli/commands/list"
|
|
"cloudsave/cmd/cli/commands/login"
|
|
"cloudsave/cmd/cli/commands/logout"
|
|
"cloudsave/cmd/cli/commands/pull"
|
|
"cloudsave/cmd/cli/commands/remote"
|
|
"cloudsave/cmd/cli/commands/remove"
|
|
"cloudsave/cmd/cli/commands/run"
|
|
"cloudsave/cmd/cli/commands/show"
|
|
"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, 0600)
|
|
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{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(&show.ShowCmd{Service: s}, "management")
|
|
|
|
subcommands.Register(&apply.ApplyCmd{Service: s}, "restore")
|
|
|
|
subcommands.Register(&remote.RemoteCmd{Service: s}, "remote")
|
|
subcommands.Register(&sync.SyncCmd{Service: s}, "remote")
|
|
subcommands.Register(&pull.PullCmd{Service: s}, "remote")
|
|
subcommands.Register(&login.LoginCmd{}, "remote")
|
|
subcommands.Register(&logout.LogoutCmd{}, "remote")
|
|
|
|
flag.Parse()
|
|
ctx := context.Background()
|
|
|
|
os.Exit(int(subcommands.Execute(ctx)))
|
|
}
|