19146: Remove unneeded special case checks, explain the needed one.
[arvados.git] / lib / cli / flags.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 package cli
6
7 import (
8         "flag"
9
10         "git.arvados.org/arvados.git/lib/cmd"
11         "rsc.io/getopt"
12 )
13
14 type LegacyFlagValues struct {
15         Format  string
16         DryRun  bool
17         Short   bool
18         Verbose bool
19 }
20
21 func LegacyFlagSet() (cmd.FlagSet, *LegacyFlagValues) {
22         values := &LegacyFlagValues{Format: "json"}
23         flags := getopt.NewFlagSet("", flag.ContinueOnError)
24         flags.BoolVar(&values.DryRun, "dry-run", false, "Don't actually do anything")
25         flags.Alias("n", "dry-run")
26         flags.StringVar(&values.Format, "format", values.Format, "Output format: json, yaml, or uuid")
27         flags.Alias("f", "format")
28         flags.BoolVar(&values.Short, "short", false, "Return only UUIDs (equivalent to --format=uuid)")
29         flags.Alias("s", "short")
30         flags.BoolVar(&values.Verbose, "verbose", false, "Print more debug/progress messages on stderr")
31         flags.Alias("v", "verbose")
32         return flags, values
33 }