matejak / argbash

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

Fluent API like commands #166

Closed auwsom closed 2 years ago

auwsom commented 2 years ago

Hi, Argbash looks awesome. I found it looking for Fluent API like command syntax for bash (as is now commonly used, by projects like Git, Docker, Kubernetes, etc.). This just uses positional args instead of double dash flags.

Is Argbash compatible with this? Any suggestions for things like nested commands? Would these just be defined by adding 'penultimate' /second to last positional arguments and such? Is there a "third-to-last" argument, etc (I'm not sure if the above mentioned packages even use a third level)? And will each level autocomplete?

Is Argbash used in the above projects? Or do you know if they use a utility for this or roll-their-own?

Thank you

matejak commented 2 years ago

Argbash is a utility to generate traditional parsing code, and it doesn't support subparsers or commands, so implementing a script that would behave like .e.g. git is not possible with Argbash. You are stuck with the GNU standard plus some extra convenience stuff. You can easily see that Argbash is used by a particular project by searching for the autogenerated code in their Bash scripts, but so far not many projects harness Argbash power. Most projects are not written in Bash anyway, so Argbash doesn't apply to them.

auwsom commented 2 years ago

@matejak okay, thanks. In case anyone stumbles here, I found a SO page describing solutions I think may work: https://stackoverflow.com/questions/5302650/multi-level-bash-completion