You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I do a lot of wrapping commands with argc. Generally, I include an escape hatch to pass arguments directly to the wrapped program, and this works well (post #232 🙏) using argc my-command -- --foo-bar.
A useful addition to argc might be an "external subcommand" feature. Basically, when there is an external subcommand in play, as soon as an unsupported argument is found, all remaining arguments get treated as positional, even if argc would otherwise recognize them. There's a few ways this would work:
Instead of @arg args+ we use @remaining_args args+ or something (@rest, @remainder, ...). Must be after all @arg, and after this starts to match, it consumes the rest of the input, ignoring further flags and options.
Instead of @arg args+ we use @arg args... or some other sigil. Same idea.
We add some @meta external_subcommand or something which applies this rule to the last @arg.
Here's a quick example:
#!/usr/bin/env bash# @describe Example Argcfileset -eu
# @cmd Wrapper that works today (wraps terraform)## Example: run with auto-approval# argc terraform apply -- -auto-approve# @arg subcommand Subcommand for terraform# @arg args* Additional arguments for terraform# @option -e --environment=production Name of the environment to operate interraform() {
echo terraform -chdir=terraform "${argc_subcommand:?}" -var-file="${argc_environment:?}.tfvars"${args_args+"${argc_args[@]}"}
}
# @cmd Wrapper that would be nice (1st idea)## Example: run with auto-approval# argc terraform2 apply -auto-approve# @arg subcommand Subcommand for terraform# @remaining_args args Additional arguments for terraform# @option -e --environment=production Name of the environment to operate interraform2() {
echo terraform -chdir=terraform "${argc_subcommand:?}" -var-file="${argc_environment:?}.tfvars"${args_args+"${argc_args[@]}"}
}
# @cmd Wrapper that would be nice (2nd idea)## Example: run with auto-approval# argc terraform3 apply -auto-approve# @arg subcommand Subcommand for terraform# @arg args... Additional arguments for terraform# @option -e --environment=production Name of the environment to operate interraform3() {
echo terraform -chdir=terraform "${argc_subcommand:?}" -var-file="${argc_environment:?}.tfvars"${args_args+"${argc_args[@]}"}
}
# @cmd Wrapper that would be nice (3rd idea)## Example: run with auto-approval# argc terraform4 apply -auto-approve# @arg subcommand Subcommand for terraform# @arg args* Additional arguments for terraform# @option -e --environment=production Name of the environment to operate in# @meta external_subcommandterraform4() {
echo terraform -chdir=terraform "${argc_subcommand:?}" -var-file="${argc_environment:?}.tfvars"${args_args+"${argc_args[@]}"}
}
if!command -v argc >/dev/null;thenecho"This command requires argc. Install from https://github.com/sigoden/argc">&2exit 100
fieval"$(argc --argc-eval "$0""$@")"
The text was updated successfully, but these errors were encountered:
I do a lot of wrapping commands with argc. Generally, I include an escape hatch to pass arguments directly to the wrapped program, and this works well (post #232 🙏) using
argc my-command -- --foo-bar
.A useful addition to argc might be an "external subcommand" feature. Basically, when there is an external subcommand in play, as soon as an unsupported argument is found, all remaining arguments get treated as positional, even if argc would otherwise recognize them. There's a few ways this would work:
@arg args+
we use@remaining_args args+
or something (@rest
,@remainder
, ...). Must be after all@arg
, and after this starts to match, it consumes the rest of the input, ignoring further flags and options.@arg args+
we use@arg args...
or some other sigil. Same idea.@meta external_subcommand
or something which applies this rule to the last@arg
.Here's a quick example:
The text was updated successfully, but these errors were encountered: