Bash argument parsing code generator
Bashscripts that should accept arguments?
getoptsdoesn't support long options, there is no widely-accepted
Bashmodule to do the task and some solutions don't work on all platforms (Linux, OSX, MSW)...
Argbasha try and stop being terrorized by those pesky arguments! With Argbash, you will get:
Argbashto regenerate the parsing part of your script easily).
Argbash-aware scripts by wrapping them by higher-level
Argbash-aware ones conveniently, without duplicating code.
cd resources && make install(you may want to run
sudo make install PREFIX=/usrfor a system-wide installation).
Make your existing script powered by
Argbashin a couple of minutes. Explore various Argbash flavours:
|Argbash online||Use it if you want to try Argbash without installing it and you have permanent access to the Internet.|
|Argbash CLI||Install the package to have
argbashready locally all the time.
|Argbash Docker||Pretty much like Argbash CLI, but you don't have to install it, you just download the image.|
Argbash is not a parsing library, but it is rather a code generator that generates a bash library tailor-made for your script. It lets you to describe arguments your script should take and then, you can generate the
bashparsing code. It stays in your script by default, but you can have it generated to a separate file and let
Argbashto include it in your script for you. In any case, you won't need
Argbashto run the script.
Argbashis very simple to use and the generated code is relatively nice to read. Moreover, argument definitions stay embedded in the script, so when you need to update the parsing logic, you just re-run the
argbashscript on the already generated script.
So by writing few comments to your script and running the Argbash's
bin/argbashover it, you will get a
bashscript with argument parsing. See the simple example source template and simple example script for the result. If you are not into long reading, let
bin/argbash-initgenerate the template for you.
Following argument types are supported:
--verbose) optional arguments and
Following outputs are available:
getopts, also tailor-made.
The utility has been inspired by Python's
Read the docs (latest stable version) for more info
bashthat can work with arrays (most likely
bash >= 3.0) (the only requirement for users - i.e. people that only execute scripts and don't make them)
autom4teutility that can work with sets (part of
autoconf >= 2.63suite)