Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix: If a variable has a default value set, when using the variab… #404

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

heshiyingx
Copy link

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.

…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 <[email protected]>
@CLAassistant
Copy link

CLAassistant commented May 28, 2024

CLA assistant check
All committers have signed the CLA.

Comment on lines -994 to 1014
} 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 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 syntax

Maybe because boolean flags have an implicit NoOptDefVal ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants