matejak / argbash

Bash argument parsing code generator
Other
1.4k stars 62 forks source link

Example with combined shorthand for flags #19

Closed btamayo closed 5 years ago

btamayo commented 7 years ago

I would like to see please an example with the following type of options, where the short bool options (flags) can be combined into a single option:

Example:

Simple:

$ tar -xvzf tarfile.tar.gz

Where the options -x, -v, -z, -f are combined.

Slightly more complex:

$ tar -rv -f abc.tar abc.txt

Flags combined + case sensitive argument (-C) + positional (filename "abc.tar.gz"):

$ tar -xvzf abc.tar.gz -C /opt/folder/

Examples from: http://www.binarytides.com/linux-tar-command/

At the moment, I'm not sure how much support argbash templates and API have for these flags.

matejak commented 7 years ago

Hello, argbash supports this functionality by default. The only thing you need is to declare multiple optional arguments with short options. I was not able to find name of this behavior, so now it is being referred to as (short) option grouping.

matejak commented 7 years ago

Can I close this as resolved, or did you have an actual example in your mind?

btamayo commented 7 years ago

@matejak Hi! Yes, sorry. :) I understand you, would be great if that were a bit clearer in the docs.

matejak commented 5 years ago

See the ARG_OPTION_STACKING macro documented at https://argbash.readthedocs.io/en/latest/guide.html#convenience-macros If you think that the documentation is insufficient, feel free to suggest improvements and reopen the issue.