bug fix: If a variable has a default value set, when using the variab…#404
Open
heshiyingx wants to merge 1 commit intospf13:masterfrom
Open
bug fix: If a variable has a default value set, when using the variab…#404heshiyingx wants to merge 1 commit intospf13:masterfrom
heshiyingx wants to merge 1 commit intospf13:masterfrom
Conversation
…le, pass arguments to the parameter in the form of "--flag arg". The default value will be overridden by the provided value. Signed-off-by: hsy <heshiyingx@126.com>
thaJeztah
reviewed
Dec 30, 2024
Comment on lines
-994
to
1014
| value = split[1] | ||
| } else if flag.NoOptDefVal != "" { | ||
| // '--flag' (arg was optional) | ||
| value = flag.NoOptDefVal | ||
| } else if len(a) > 0 { | ||
| // '--flag arg' | ||
| value = a[0] | ||
| a = a[1:] | ||
| } else if flag.NoOptDefVal != "" { | ||
| // '--flag' (arg was optional) | ||
| value = flag.NoOptDefVal | ||
| } else { |
There was a problem hiding this comment.
I haven't looked exactly why, but it looks like this patch can cause a regression; I tried using the NoOptDefVal on a flag (--pull), and it now failed when the flag before it is a boolean;
docker run -it --rm --pull=never alpine
invalid argument "--pull=never" for "--rm" flag: strconv.ParseBool: parsing "--pull=never": invalid syntaxMaybe because boolean flags have an implicit NoOptDefVal ?
There was a problem hiding this comment.
I tried using the NoOptDefVal on a flag (--pull), and it now failed when the flag before it is a boolean;
Actually; same happens without that option set on the --pull flag, and I see the same for other flags;
docker run -it --rm --label foo=bar alpine
invalid argument "--label" for "--rm" flag: strconv.ParseBool: parsing "--label": invalid syntax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If a variable has a default value set, when using the variable, pass arguments to the parameter in the form of '--flag arg'. The default value will be overridden by the provided value.