Skip to content
/ etcd Public
forked from etcd-io/etcd

Commit

Permalink
ctlv3: error on --order or --sort-by missing
Browse files Browse the repository at this point in the history
Address etcd-io#6671.
  • Loading branch information
gyuho committed Oct 18, 2016
1 parent 20bdb31 commit ea4ed1f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions etcdctl/ctlv3/command/get_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package command

import (
"errors"
"fmt"
"strings"

Expand Down Expand Up @@ -105,6 +106,13 @@ func getGetOp(cmd *cobra.Command, args []string) (string, []clientv3.OpOption) {
opts = append(opts, clientv3.WithRev(getRev))
}

if getSortOrder == "" && getSortTarget != "" {
ExitWithError(ExitBadFeature, errors.New("missing sort order (--order)"))
}
if getSortOrder != "" && getSortTarget == "" {
ExitWithError(ExitBadFeature, errors.New("missing sort target (--sort-by)"))
}

sortByOrder := clientv3.SortNone
sortOrder := strings.ToUpper(getSortOrder)
switch {
Expand Down

0 comments on commit ea4ed1f

Please sign in to comment.