Rename params to better reflect their purpose

This commit is contained in:
Joel Watson 2020-11-10 10:44:09 -06:00
parent 5ad0db73c8
commit 1ef259b093
2 changed files with 15 additions and 15 deletions

View File

@ -31,19 +31,19 @@ type cmd struct {
format string format string
// flags // flags
detailed bool kvDetails bool
depth int kvDepth int
filter string kvFilter string
} }
func (c *cmd) init() { func (c *cmd) init() {
c.flags = flag.NewFlagSet("", flag.ContinueOnError) c.flags = flag.NewFlagSet("", flag.ContinueOnError)
c.flags.BoolVar(&c.detailed, "detailed", false, c.flags.BoolVar(&c.kvDetails, "kvdetails", false,
"Provides a detailed KV space usage breakdown for any KV data that's been stored.") "Provides a detailed KV space usage breakdown for any KV data that's been stored.")
c.flags.IntVar(&c.depth, "depth", 2, c.flags.IntVar(&c.kvDepth, "kvdepth", 2,
"Must be used with -detailed. The key prefix depth used to breakdown KV store data. Defaults to 2.") "Can only be used with -kvdetails. The key prefix depth used to breakdown KV store data. Defaults to 2.")
c.flags.StringVar(&c.filter, "filter", "", c.flags.StringVar(&c.kvFilter, "kvfilter", "",
"Must be used with -detailed. Limits KV key breakdown using this prefix filter.") "Can only be used with -kvdetails. Limits KV key breakdown using this prefix filter.")
c.flags.StringVar( c.flags.StringVar(
&c.format, &c.format,
"format", "format",
@ -270,7 +270,7 @@ func (c *cmd) enhance(file io.Reader) (SnapshotInfo, error) {
} }
func (c *cmd) kvEnhance(keyType string, val interface{}, size int, info *SnapshotInfo) { func (c *cmd) kvEnhance(keyType string, val interface{}, size int, info *SnapshotInfo) {
if c.detailed { if c.kvDetails {
if keyType != "KVS" { if keyType != "KVS" {
return return
} }
@ -286,7 +286,7 @@ func (c *cmd) kvEnhance(keyType string, val interface{}, size int, info *Snapsho
// check for whether a filter is specified. if it is, skip // check for whether a filter is specified. if it is, skip
// any keys that don't match. // any keys that don't match.
if len(c.filter) > 0 && !strings.HasPrefix(v.(string), c.filter) { if len(c.kvFilter) > 0 && !strings.HasPrefix(v.(string), c.kvFilter) {
break break
} }
@ -294,8 +294,8 @@ func (c *cmd) kvEnhance(keyType string, val interface{}, size int, info *Snapsho
// handle the situation where the key is shorter than // handle the situation where the key is shorter than
// the specified depth. // the specified depth.
actualDepth := c.depth actualDepth := c.kvDepth
if c.depth > len(split) { if c.kvDepth > len(split) {
actualDepth = len(split) actualDepth = len(split)
} }
prefix := strings.Join(split[0:actualDepth], "/") prefix := strings.Join(split[0:actualDepth], "/")

View File

@ -109,7 +109,7 @@ more details about snapshot internals.
#### Command Options #### Command Options
- `-detailed` - Optional, provides a space usage breakdown for any KV data stored in Consul. - `-kvdetails` - Optional, provides a space usage breakdown for any KV data stored in Consul.
- `-depth` - Must be used with `-detailed`. Used to adjust the grouping level of keys. Defaults to 2. - `-kvdepth` - Can only be used with `-kvdetails`. Used to adjust the grouping level of keys. Defaults to 2.
- `-filter` - Must be used with `-detailed`. Used to specify a key prefix that excludes keys that don't match. - `-kvfilter` - Can only be used with `-kvdetails`. Used to specify a key prefix that excludes keys that don't match.
- `-format` - Optional, allows from changing the output to JSON. Parameters accepted are "pretty" and "JSON". - `-format` - Optional, allows from changing the output to JSON. Parameters accepted are "pretty" and "JSON".