glab token create duration help text is misleading
Checklist
-
I'm using the latest version of the extension (Run glab --version)- Extension version:
glab 1.77.0 (edbbb739)
- Extension version:
-
Operating system and version: Debian testing -
Gitlab.com or self-managed instance? self-managed instance -
GitLab version (if self-managed) 18.5.2 (45f7473ea37) -
I have performed glab auth statusto check for authentication issues -
Run the command in debug mode (like DEBUG=true glab mr list) and attach any useful output
Summary
glab token create shows misleading/incorrect help texts about duration
Steps to reproduce
$ glab token create -h
...
FLAGS
-D --duration Sets the token duration, in hours. Maximum of 8760. Examples: 24h, 168h, 504h. (720h0m0s)
$ glab token create --user @me --scope read_registry -D 8 tmp
ERROR
Invalid argument "8" for "-D, --duration" flag: time: missing unit in duration "8".
$ glab token create --user @me --scope read_registry -D 8h tmp
ERROR
Duration must be in days..
$ glab token create --user @me --scope read_registry -D 1d tmp
ERROR
Invalid argument "1d" for "-D, --duration" flag: time: unknown unit "d" in duration "1d".
What is the current bug behavior?
-h says duration is in hours but trying to set in hours results in error that is must in days. Also when -h specifically mentions hours then I would assume it would work without unit but that doesn't work. Also d doesn't work as day units.
What is the expected correct behavior?
Fix -h text to mention it requiring full days and say unit is required. Preferably use days instead of hours.
Fix validation error to mention it must be in full days.
Fix d to work as unit of days.
Possible fixes
https://gitlab.com/gitlab-org/cli/-/blob/main/internal/commands/token/create/create.go#L104
And since go Duration doesn't support anything larger than hour due to different length days (i.e. daylight savings time) you need to add own parser for this.