Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix parsing of negative values for duration flags (#2471)
* Fix parsing of negative values for duration flags * In order to be backward compatible with Golang flags, for flags that are specified using single hyphens, we add another hyphen so that pflag can process it correctly. This augmentation must be done on flags and not on values. The way we currently do that is we determine all args that are prefixed with a single hyphen and are not numbers since negative numbers are prefixed with hyphens. This logic however doesn't work for duration flags since a duration such as -1s is a valid duration, not parseable as a number and yet since it's a value and not a flag, should not be prefixed with an additional hyphen. This PR makes the aforementioned logic more robust by compiling a list of flags and adding an additional hyphen only if the arg is a flag. * Add tests for each supported data type.
- Loading branch information