etcdctl, etcdctlv3: add help message for non-valid value arg
Unix commands interprets argument value of first character '-' as a flag. And this won't be fixed in our upstream CLI libraries. This adds help message to show users workarounds. Addressing https://github.com/coreos/etcd/issues/2020.release-2.3
parent
ca9ad6897a
commit
054db2e3cf
|
@ -29,6 +29,12 @@ func NewSetCommand() cli.Command {
|
||||||
Name: "set",
|
Name: "set",
|
||||||
Usage: "set the value of a key",
|
Usage: "set the value of a key",
|
||||||
ArgsUsage: "<key> <value>",
|
ArgsUsage: "<key> <value>",
|
||||||
|
Description: `Set sets the value of a key.
|
||||||
|
|
||||||
|
When <value> begins with '-', <value> is interpreted as a flag.
|
||||||
|
Insert '--' for workaround:
|
||||||
|
|
||||||
|
$ set -- <key> <value>`,
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live"},
|
cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live"},
|
||||||
cli.StringFlag{Name: "swap-with-value", Value: "", Usage: "previous value"},
|
cli.StringFlag{Name: "swap-with-value", Value: "", Usage: "previous value"},
|
||||||
|
|
|
@ -31,9 +31,18 @@ var (
|
||||||
// NewPutCommand returns the cobra command for "put".
|
// NewPutCommand returns the cobra command for "put".
|
||||||
func NewPutCommand() *cobra.Command {
|
func NewPutCommand() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "put",
|
Use: "put [options] <key> <value>",
|
||||||
Short: "Put puts the given key into the store.",
|
Short: "Put puts the given key into the store.",
|
||||||
Run: putCommandFunc,
|
Long: `
|
||||||
|
Put puts the given key into the store.
|
||||||
|
|
||||||
|
When <value> begins with '-', <value> is interpreted as a flag.
|
||||||
|
Insert '--' for workaround:
|
||||||
|
|
||||||
|
$ put <key> -- <value>
|
||||||
|
$ put -- <key> <value>
|
||||||
|
`,
|
||||||
|
Run: putCommandFunc,
|
||||||
}
|
}
|
||||||
cmd.Flags().StringVar(&leaseStr, "lease", "0", "lease ID attached to the put key")
|
cmd.Flags().StringVar(&leaseStr, "lease", "0", "lease ID attached to the put key")
|
||||||
return cmd
|
return cmd
|
||||||
|
|
Loading…
Reference in New Issue