From 054db2e3cf3d1d2dd87bfc24a7dc71cc0cd3a168 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Wed, 13 Jan 2016 09:25:24 -0800 Subject: [PATCH] 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. --- etcdctl/command/set_command.go | 6 ++++++ etcdctlv3/command/put_command.go | 13 +++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/etcdctl/command/set_command.go b/etcdctl/command/set_command.go index 9a64a78e9..589701f5a 100644 --- a/etcdctl/command/set_command.go +++ b/etcdctl/command/set_command.go @@ -29,6 +29,12 @@ func NewSetCommand() cli.Command { Name: "set", Usage: "set the value of a key", ArgsUsage: " ", + Description: `Set sets the value of a key. + + When begins with '-', is interpreted as a flag. + Insert '--' for workaround: + + $ set -- `, Flags: []cli.Flag{ cli.IntFlag{Name: "ttl", Value: 0, Usage: "key time-to-live"}, cli.StringFlag{Name: "swap-with-value", Value: "", Usage: "previous value"}, diff --git a/etcdctlv3/command/put_command.go b/etcdctlv3/command/put_command.go index 7b587cc23..2225aa1fb 100644 --- a/etcdctlv3/command/put_command.go +++ b/etcdctlv3/command/put_command.go @@ -31,9 +31,18 @@ var ( // NewPutCommand returns the cobra command for "put". func NewPutCommand() *cobra.Command { cmd := &cobra.Command{ - Use: "put", + Use: "put [options] ", Short: "Put puts the given key into the store.", - Run: putCommandFunc, + Long: ` +Put puts the given key into the store. + +When begins with '-', is interpreted as a flag. +Insert '--' for workaround: + +$ put -- +$ put -- +`, + Run: putCommandFunc, } cmd.Flags().StringVar(&leaseStr, "lease", "0", "lease ID attached to the put key") return cmd