package main import ( "bytes" "fmt" "os" ecli "edge-infra.dev/pkg/lib/cli" "edge-infra.dev/pkg/lib/fog" "edge-infra.dev/pkg/lib/runtime/version" etcdmanager "edge-infra.dev/pkg/sds/etcd/manager" ) func main() { log := fog.New().WithName("etcd-manager") if len(os.Args) < 2 { err := fmt.Errorf("invalid arguments") log.Error(err, "Usage: /app/cmd/sds/etcd/manager/etcdmanager_container.binary ") os.Exit(1) } switch os.Args[1] { // if the subcommand is help, print the usage and exit case "help", "-h", "--help": log.V(0).Info("Usage: /app/cmd/sds/etcd/manager/etcdmanager_container.binary ") // if the subcommand is version, print the version and exit case "version", "-v", "--version": v := version.New() buf := new(bytes.Buffer) ecli.Version(buf, v) log.V(0).Info(buf.String()) // if the subcommand is run, run the run command with the given arguments case "run": err := etcdmanager.Run() log.Error(err, "error in etcdmanager run") os.Exit(1) // if the subcommand is anything else, print the usage and exit default: err := fmt.Errorf("invalid subcommand") log.Error(err, "Usage: /app/cmd/sds/etcd/manager/etcdmanager_container.binary ", "subcommand", os.Args[1]) os.Exit(1) } os.Exit(0) }