You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be useful if there was a way to distinguish between passing a string flag a blank string (command -f "") and the absence of the flag (command).
Currently both will return "" from c.String("f")
Our use case:
We have a command to update a resource via an API. Fields that can be updated are represented by different CLI flags. One of the fields on the resource is a string that can be blank. We would like users to be able to set the field to the blank string.
#Setting the field to non-blank stringcommand -f "string"#Setting the field to blank stringcommand -f ""
To do this currently we have to have another flag to reset the field.
command --clear-field
This is annoying because it means we have two flags for a single field and have to handle cases where both flags are passed.
Thanks!
The text was updated successfully, but these errors were encountered:
c.IsSet() requires you to manually check this and generate an appropiate error message; would it make sense to delegate this to the parser as well, by setting a { Required = true } field in the generator struct of the Flag?
Feature Request
It would be useful if there was a way to distinguish between passing a string flag a blank string (
command -f ""
) and the absence of the flag (command
).Currently both will return
""
fromc.String("f")
Our use case:
We have a command to update a resource via an API. Fields that can be updated are represented by different CLI flags. One of the fields on the resource is a string that can be blank. We would like users to be able to set the field to the blank string.
To do this currently we have to have another flag to reset the field.
command --clear-field
This is annoying because it means we have two flags for a single field and have to handle cases where both flags are passed.
Thanks!
The text was updated successfully, but these errors were encountered: