Nested Options
For when flat arguments aren't enough and you want to pretend you're writing JSON in terminal arguments. This feature creates an associative array with passed keys and values.
Usage
Use --nested with generate or parse.
Syntax: --nested 'arg-name "description" [options]'
Arguments & Options
- arg-name: The namespace name.
- description: Description for the help message.
- --one-of: Restrict accepted keys to a specific list. Repeatable.
- --complete: Bash built-in completion for keys. Repeatable.
- --complete-custom: Custom dynamic suggestion for keys. Repeatable.
>
parseArger generate --output my-script --nested 'opt-ns "a nested option"'
This generates a parser that accepts arguments in the format --namespace-key value.
./my-script --opt-ns-a "value" --opt-ns-b "b value" --opt-ns-option "my opt"Accessing Values
Inside bash, you get an associative array.
echo $_arg_opt_ns["a"]
# Output: value
echo $_arg_opt_ns["b"]
# Output: b valueUse Cases
Passing options to wrapped commands. If your script wraps another CLI tool, you can collect specific options for that tool in a namespace and pass them along.