Skip to content

Commit

Permalink
add negative to cli (#3888)
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed Jan 4, 2023
1 parent de76db0 commit 8f88f7d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions osmoutils/osmocli/parsers.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ func parseFieldFromDirectlySetFlag(fVal reflect.Value, fType reflect.StructField
}

func ParseFieldFromArg(fVal reflect.Value, fType reflect.StructField, arg string) error {
// We cant pass in a negative number due to the way pflags works...
// This is an (extraordinarily ridiculous) workaround that checks if a negative int is encapsulated in square brackets,
// and if so, trims the square brackets
if strings.HasPrefix(arg, "[") && strings.HasSuffix(arg, "]") && arg[1] == '-' {
arg = strings.TrimPrefix(arg, "[")
arg = strings.TrimSuffix(arg, "]")
}

switch fType.Type.Kind() {
// SetUint allows anyof type u8, u16, u32, u64, and uint
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
Expand Down

0 comments on commit 8f88f7d

Please sign in to comment.