cos-gpu-installer-v2: Add main.go
Change-Id: Ic62e67fcfa1deeac81d383787781f7732ae832f5
diff --git a/src/cmd/cos_gpu_installer/main.go b/src/cmd/cos_gpu_installer/main.go
new file mode 100644
index 0000000..4bb1a6f
--- /dev/null
+++ b/src/cmd/cos_gpu_installer/main.go
@@ -0,0 +1,32 @@
+// Package main is the program entrance.
+package main
+
+import (
+ "context"
+ "flag"
+ "os"
+
+ log "github.com/golang/glog"
+ "github.com/google/subcommands"
+
+ "cmd/cos_gpu_installer/internal/commands"
+ "pkg/utils"
+)
+
+func main() {
+ // Always log to stderr for easy debugging.
+ flag.Set("alsologtostderr", "true")
+ flag.Parse()
+
+ log.Info("Checking if this is the only cos_gpu_installer that is running.")
+ utils.Flock()
+
+ subcommands.Register(subcommands.HelpCommand(), "")
+ subcommands.Register(subcommands.FlagsCommand(), "")
+ subcommands.Register(subcommands.CommandsCommand(), "")
+ subcommands.Register(&commands.InstallCommand{}, "")
+ subcommands.Register(&commands.ListCommand{}, "")
+
+ ctx := context.Background()
+ os.Exit(int(subcommands.Execute(ctx)))
+}