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

Add arguments with value to parse-generic #506

Merged
merged 1 commit into from
May 9, 2024

Conversation

andyneff
Copy link
Member

@andyneff andyneff commented May 9, 2024

A simple addition to parse-generic to support arguments that require one argument.

This is still far less strict than previous implementations like the docker compose parse which strictly only allows arguments that are defined in the code, but it opens up the use cases that generic-parser can work with by adding very little lift for the dev.

Signed-off-by: Andy Neff <andy@visionsystemsinc.com>
@andyneff andyneff requested a review from scott-vsi May 9, 2024 14:19
@andyneff andyneff enabled auto-merge May 9, 2024 14:19
@@ -116,7 +117,17 @@ function parse-generic()
while (( ${#} )); do
case "${1}" in
-*)
# Everything takes zero arguments, so no need to enumerate -d --debug -h --help --nocolor -q --quiet -s --silent -v --verbose --version
# Anything that takes one arguments from the array arguments_with_value
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Anything that takes one arguments from the array arguments_with_value
# Anything that takes one argument from the array arguments_with_value

# Everything takes zero arguments, so no need to enumerate -d --debug -h --help --nocolor -q --quiet -s --silent -v --verbose --version
# Anything that takes one arguments from the array arguments_with_value
for arg in ${arguments_with_value[@]+"${arguments_with_value[@]}"}; do
# No need to check "${arg}=", that will be handled as taking "zero argument" below
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# No need to check "${arg}=", that will be handled as taking "zero argument" below
# No need to check "${arg}=", that will be handled as taking "zero arguments" below

continue 2
fi
done
# Everything takes zero arguments, so no need to enumerate examples like: -d --debug -h --help
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Everything takes zero arguments, so no need to enumerate examples like: -d --debug -h --help
# Everything else takes zero arguments, so no need to enumerate examples like: -d --debug -h --help

linux/command_tools.bsh Show resolved Hide resolved
@andyneff andyneff merged commit aa346ec into main May 9, 2024
5 checks passed
@andyneff andyneff deleted the generic_parse_with_values branch May 9, 2024 15:32
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.

2 participants