-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Using catch_all
with required: true
#96
Comments
Alright. So you are right in observing that For now, you can work around it like so: # src/bashly.yml
name: update
help: Update one or more package
version: 0.1.0
catch_all: packages # src/root_command.sh
packages=${other_args[*]}
count=${#other_args[@]}
if [[ $count -eq 0 ]]; then
echo "Please provide at least one package"
exit 1
else
echo "updaging $count packages"
for package in $packages; do
echo "$package"
done
fi Of course, this is less ideal since the usage text implies that these extra params (
Let me think about it a little, perhaps it can be easy to implement it in the hash notation of the Keep this issue open, I will post again if I can implement it without introducing undesired complexity. |
Found another option that might be suitable: # src/bashly.yml
name: update
help: Update one or more package
version: 0.1.0
catch_all: true
args:
- name: package
help: Package name
required: true # src/root_command.sh
packages=(${args[package]} ${other_args[*]})
count=${#packages[@]}
echo "updaging $count packages"
for package in ${packages[@]}; do
echo "$package"
done # output
$ ./update -h
update - Update one or more package
Usage:
update PACKAGE [...]
... With this we create one required argument, one nameless I will still look for a way to support required |
So, I have implemented it. Using
|
@JakobGM - can I close this? |
Hi, @DannyBen!
I'm just wondering how you would recommenced using the
catch_all
approach when the additional arguments are required but of unknown length? I see that providingrequired: true
to thecatch_all
hash changes nothing, which makes sense.Thanks for the great tool,
Originally posted by @JakobGM in #70 (comment)
The text was updated successfully, but these errors were encountered: