Open your-diary opened 1 year ago
I believe this default behaviour is powered by kong
, the CLI tooling powering gum, during parsing. In turn, that dependency defaults to using time.ParseDuration
from the standard library, which does not support unit-less conversions without returning an error.
However, we can probably override this behaviour by implementing the MapperValue interface for the timeout field, still using time.ParseDuration
, but handling the "missing unit" case whenever a unit is... Missing πΆβπ«οΈ.
Unfortunately, that "missing unit" error is not exported from time
, so I feel the switch statement might be a bit weird (...string.Contains
?). Furthermore, it would probably require swapping out the timeout behaviours for all the CLI Options, not just input/options.go
, for a homogenous interface.
Is your feature request related to a problem? Please describe. Currently, you always have to specify the unit of timeout in
--timeout
like--timeout 10s
. Personally, this seems verbose in some cases.Describe the solution you'd like
It would be great if the unit falls back to a sensible default (e.g. second) when it is not explicitly specified, making
--timeout 10
and--timeout 10s
the same. In many UNIX programs (e.g.curl
,ping
, etc.), the default unit is second.Or, at least, we may want to explicitly states there should be a unit in the help page. The current description is