-
-
Notifications
You must be signed in to change notification settings - Fork 87
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 key-value parameters #482
Comments
|
Here are some examples: gcc --param name=value -D name=definition -A predicate=answer
objcopy --set-section-flags sectionpattern=flags # AND MANY OTHERS
ps -o pid=X,comm=Y
openssh -header name=value
ssh-keygen -M generate -O bits=2048 moduli-2048.candidates
python -X utf8=0
awk -v var=value -W random=num -W sprintf=num
kubectl config view -o jsonpath='{.users[].name}'
docker [container|network|plugin] ls --filter key=value
docker run --label key=value
docker volume create --driver local --opt type=btrfs --opt device=/dev/sda2
curl --data-urlencode name=val https://example.com
blkid --match-token NAME=value
Key-value argument options I feel are more common, but are also more difficult to search for. Here are some examples I could think of:
Parsing to a dictionary may be unnecessary. Allowing the user to set environment variables as done in the example commands is sufficient for what I'm doing and seems to be standard. |
Well - nothing in bashly prevents you from doing this. The only difference is terminology, and who is responsible for parsing the values. From a framework perspective, your x=y pairs are values, either for a flag, or as an argument: command argument=value --flag key=value
+------------+ +-------+
arg value flag value Parsing these further to extract the two sides of the key=value pair is left up to you. Bashly conforms to this standard:
and supports these alternative formats:
As there is no data structure in bash that can hold this nested dictionary - I am curious, how do you expect to receive this user input? In a richer language, I would expect args = {
'--flag' => {
'key' => 'value'
}
}
# or in other words:
args['--flag']['key'] = 'value' but this cannot be done in bash. At any rate, I believe you should use one of these options:
|
As far as I see it there are 2 good options for how to receive the input:
|
No, none of these are good in my opinion.
Nothing stops you from having any value (with equal signs, commas) in bashly. However, how you parse it and how you store it is up to you, and should be quite easy, especially using one of the facilities I mentioned earlier. |
I have created the key-value-pairs example to demonstrate how to easily support key=value pairs either for arguments or flags. Hope this helps. |
Description
Add the ability to parse key value pairs for parameters. For example I want to be able to do this:
or this
It would also be good to have
allowedKeys
andallowedValues
lists so the keys and/or values can be validated similar to how flags and args are currently validated.The text was updated successfully, but these errors were encountered: