11453: Merge branch 'master' into 11453-federated-tokens
[arvados.git] / tools / arv-sync-groups / arv-sync-groups.go
index d7efdefb6f68a791c1417c05357b5f2636227e84..6b4781c3549627f0f9874cc0be734b611b41c5dd 100644 (file)
@@ -19,6 +19,8 @@ import (
        "git.curoverse.com/arvados.git/sdk/go/arvados"
 )
 
+var version = "dev"
+
 type resourceList interface {
        Len() int
        GetItems() []interface{}
@@ -150,6 +152,10 @@ func ParseFlags(config *ConfigParams) error {
                "verbose",
                false,
                "Log informational messages. Off by default.")
+       getVersion := flags.Bool(
+               "version",
+               false,
+               "Print version information and exit.")
        parentGroupUUID := flags.String(
                "parent-group-uuid",
                "",
@@ -158,6 +164,12 @@ func ParseFlags(config *ConfigParams) error {
        // Parse args; omit the first arg which is the command name
        flags.Parse(os.Args[1:])
 
+       // Print version information if requested
+       if *getVersion {
+               fmt.Printf("arv-sync-groups %s\n", version)
+               os.Exit(0)
+       }
+
        // Input file as a required positional argument
        if flags.NArg() == 0 {
                return fmt.Errorf("please provide a path to an input file")
@@ -276,7 +288,7 @@ func doMain(cfg *ConfigParams) error {
        }
        defer f.Close()
 
-       log.Printf("Group sync starting. Using %q as users id and parent group UUID %q", cfg.UserID, cfg.ParentGroupUUID)
+       log.Printf("arv-sync-groups %s started. Using %q as users id and parent group UUID %q", version, cfg.UserID, cfg.ParentGroupUUID)
 
        // Get the complete user list to minimize API Server requests
        allUsers := make(map[string]arvados.User)