Skip to content

Commit

Permalink
Merge pull request docker#4834 from thaJeztah/flags_dont_varp
Browse files Browse the repository at this point in the history
cli/command: don't use pflags.XXXVarP for flags without shorthand
  • Loading branch information
thaJeztah authored Jan 29, 2024
2 parents abf8cff + dfdff11 commit 6dcf285
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cli/command/checkpoint/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command {

flags := cmd.Flags()
flags.BoolVar(&opts.leaveRunning, "leave-running", false, "Leave the container running after checkpoint")
flags.StringVarP(&opts.checkpointDir, "checkpoint-dir", "", "", "Use a custom checkpoint storage directory")
flags.StringVar(&opts.checkpointDir, "checkpoint-dir", "", "Use a custom checkpoint storage directory")

return cmd
}
Expand Down
2 changes: 1 addition & 1 deletion cli/command/checkpoint/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command {
}

flags := cmd.Flags()
flags.StringVarP(&opts.checkpointDir, "checkpoint-dir", "", "", "Use a custom checkpoint storage directory")
flags.StringVar(&opts.checkpointDir, "checkpoint-dir", "", "Use a custom checkpoint storage directory")

return cmd
}
Expand Down
2 changes: 1 addition & 1 deletion cli/command/checkpoint/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
}

flags := cmd.Flags()
flags.StringVarP(&opts.checkpointDir, "checkpoint-dir", "", "", "Use a custom checkpoint storage directory")
flags.StringVar(&opts.checkpointDir, "checkpoint-dir", "", "Use a custom checkpoint storage directory")

return cmd
}
Expand Down
2 changes: 1 addition & 1 deletion cli/command/config/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func newConfigListCommand(dockerCli command.Cli) *cobra.Command {

flags := cmd.Flags()
flags.BoolVarP(&listOpts.Quiet, "quiet", "q", false, "Only display IDs")
flags.StringVarP(&listOpts.Format, "format", "", "", flagsHelper.FormatHelp)
flags.StringVar(&listOpts.Format, "format", "", flagsHelper.FormatHelp)
flags.VarP(&listOpts.Filter, "filter", "f", "Filter output based on conditions provided")

return cmd
Expand Down
4 changes: 2 additions & 2 deletions cli/command/container/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ func NewExecCommand(dockerCli command.Cli) *cobra.Command {
flags := cmd.Flags()
flags.SetInterspersed(false)

flags.StringVarP(&options.DetachKeys, "detach-keys", "", "", "Override the key sequence for detaching a container")
flags.StringVar(&options.DetachKeys, "detach-keys", "", "Override the key sequence for detaching a container")
flags.BoolVarP(&options.Interactive, "interactive", "i", false, "Keep STDIN open even if not attached")
flags.BoolVarP(&options.TTY, "tty", "t", false, "Allocate a pseudo-TTY")
flags.BoolVarP(&options.Detach, "detach", "d", false, "Detached mode: run command in the background")
flags.StringVarP(&options.User, "user", "u", "", `Username or UID (format: "<name|uid>[:<group|gid>]")`)
flags.BoolVarP(&options.Privileged, "privileged", "", false, "Give extended privileges to the command")
flags.BoolVar(&options.Privileged, "privileged", false, "Give extended privileges to the command")
flags.VarP(&options.Env, "env", "e", "Set environment variables")
flags.SetAnnotation("env", "version", []string{"1.25"})
flags.Var(&options.EnvFile, "env-file", "Read in a file of environment variables")
Expand Down
2 changes: 1 addition & 1 deletion cli/command/container/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func NewPsCommand(dockerCLI command.Cli) *cobra.Command {
flags.BoolVar(&options.noTrunc, "no-trunc", false, "Don't truncate output")
flags.BoolVarP(&options.nLatest, "latest", "l", false, "Show the latest created container (includes all states)")
flags.IntVarP(&options.last, "last", "n", -1, "Show n last created containers (includes all states)")
flags.StringVarP(&options.format, "format", "", "", flagsHelper.FormatHelp)
flags.StringVar(&options.format, "format", "", flagsHelper.FormatHelp)
flags.VarP(&options.filter, "filter", "f", "Filter output based on conditions provided")

return cmd
Expand Down
2 changes: 1 addition & 1 deletion cli/command/registry/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func NewLoginCommand(dockerCli command.Cli) *cobra.Command {

flags.StringVarP(&opts.user, "username", "u", "", "Username")
flags.StringVarP(&opts.password, "password", "p", "", "Password")
flags.BoolVarP(&opts.passwordStdin, "password-stdin", "", false, "Take the password from stdin")
flags.BoolVar(&opts.passwordStdin, "password-stdin", false, "Take the password from stdin")

return cmd
}
Expand Down
2 changes: 1 addition & 1 deletion cli/command/secret/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func newSecretListCommand(dockerCli command.Cli) *cobra.Command {

flags := cmd.Flags()
flags.BoolVarP(&options.quiet, "quiet", "q", false, "Only display IDs")
flags.StringVarP(&options.format, "format", "", "", flagsHelper.FormatHelp)
flags.StringVar(&options.format, "format", "", flagsHelper.FormatHelp)
flags.VarP(&options.filter, "filter", "f", "Filter output based on conditions provided")

return cmd
Expand Down
2 changes: 1 addition & 1 deletion cli/command/swarm/ipnet_slice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func equalCIDR(c1 net.IPNet, c2 net.IPNet) bool {

func setUpIPNetFlagSet(ipsp *[]net.IPNet) *pflag.FlagSet {
f := pflag.NewFlagSet("test", pflag.ContinueOnError)
f.VarP(newIPNetSliceValue([]net.IPNet{}, ipsp), "cidrs", "", "Command separated list!")
f.Var(newIPNetSliceValue([]net.IPNet{}, ipsp), "cidrs", "Command separated list!")
return f
}

Expand Down

0 comments on commit 6dcf285

Please sign in to comment.