etcdctl/ctlv3: fix fmt test warnings

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
Gyuho Lee 2018-05-09 13:17:55 -07:00
parent 775e9d5ba6
commit 167c711467
5 changed files with 14 additions and 16 deletions

View File

@ -43,7 +43,7 @@ func NewDelCommand() *cobra.Command {
// delCommandFunc executes the "del" command.
func delCommandFunc(cmd *cobra.Command, args []string) {
key, opts := getDelOp(cmd, args)
key, opts := getDelOp(args)
ctx, cancel := commandCtx(cmd)
resp, err := mustClientFromCmd(cmd).Delete(ctx, key, opts...)
cancel()
@ -53,7 +53,7 @@ func delCommandFunc(cmd *cobra.Command, args []string) {
display.Del(*resp)
}
func getDelOp(cmd *cobra.Command, args []string) (string, []clientv3.OpOption) {
func getDelOp(args []string) (string, []clientv3.OpOption) {
if len(args) == 0 || len(args) > 2 {
ExitWithError(ExitBadArgs, fmt.Errorf("del command needs one argument as key and an optional argument as range_end."))
}

View File

@ -56,7 +56,7 @@ func NewGetCommand() *cobra.Command {
// getCommandFunc executes the "get" command.
func getCommandFunc(cmd *cobra.Command, args []string) {
key, opts := getGetOp(cmd, args)
key, opts := getGetOp(args)
ctx, cancel := commandCtx(cmd)
resp, err := mustClientFromCmd(cmd).Get(ctx, key, opts...)
cancel()
@ -74,7 +74,7 @@ func getCommandFunc(cmd *cobra.Command, args []string) {
display.Get(*resp)
}
func getGetOp(cmd *cobra.Command, args []string) (string, []clientv3.OpOption) {
func getGetOp(args []string) (string, []clientv3.OpOption) {
if len(args) == 0 {
ExitWithError(ExitBadArgs, fmt.Errorf("range command needs arguments."))
}

View File

@ -65,7 +65,7 @@ will store the content of the file to <key>.
// putCommandFunc executes the "put" command.
func putCommandFunc(cmd *cobra.Command, args []string) {
key, value, opts := getPutOp(cmd, args)
key, value, opts := getPutOp(args)
ctx, cancel := commandCtx(cmd)
resp, err := mustClientFromCmd(cmd).Put(ctx, key, value, opts...)
@ -76,7 +76,7 @@ func putCommandFunc(cmd *cobra.Command, args []string) {
display.Put(*resp)
}
func getPutOp(cmd *cobra.Command, args []string) (string, string, []clientv3.OpOption) {
func getPutOp(args []string) (string, string, []clientv3.OpOption) {
if len(args) == 0 {
ExitWithError(ExitBadArgs, fmt.Errorf("put command needs 1 argument and input from stdin or 2 arguments."))
}

View File

@ -28,9 +28,7 @@ import (
"github.com/spf13/cobra"
)
var (
txnInteractive bool
)
var txnInteractive bool
// NewTxnCommand returns the cobra command for "txn".
func NewTxnCommand() *cobra.Command {
@ -129,17 +127,17 @@ func parseRequestUnion(line string) (*clientv3.Op, error) {
put := NewPutCommand()
put.Run = func(cmd *cobra.Command, args []string) {
key, value, opts := getPutOp(cmd, args)
key, value, opts := getPutOp(args)
opc <- clientv3.OpPut(key, value, opts...)
}
get := NewGetCommand()
get.Run = func(cmd *cobra.Command, args []string) {
key, opts := getGetOp(cmd, args)
key, opts := getGetOp(args)
opc <- clientv3.OpGet(key, opts...)
}
del := NewDelCommand()
del.Run = func(cmd *cobra.Command, args []string) {
key, opts := getDelOp(cmd, args)
key, opts := getDelOp(args)
opc <- clientv3.OpDelete(key, opts...)
}
cmds := &cobra.Command{SilenceErrors: true}

View File

@ -258,9 +258,9 @@ func parseWatchArgs(osArgs, commandArgs []string, envKey, envRange string, inter
}
flagset := NewWatchCommand().Flags()
if err := flagset.Parse(watchArgs); err != nil {
if perr := flagset.Parse(watchArgs); perr != nil {
watchPrefix, watchRev, watchPrevKey = false, 0, false
return nil, nil, err
return nil, nil, perr
}
pArgs := flagset.Args()
@ -298,8 +298,8 @@ func parseWatchArgs(osArgs, commandArgs []string, envKey, envRange string, inter
if interactive {
flagset := NewWatchCommand().Flags()
if err := flagset.Parse(argsWithSep); err != nil {
return nil, nil, err
if perr := flagset.Parse(argsWithSep); perr != nil {
return nil, nil, perr
}
watchArgs = flagset.Args()