Others
======

Utilities
---------

You want to write a script that does argument parsing and don't like ``Argbash`` or you just want to find out how awesome it really is?
Then read through this list of influences and/or alternatives!

* Python ``argparse``: The main inspiration: https://docs.python.org/3/library/argparse.html

  * Pros:

    * Works really well.
    * Has more features.

  * Cons:

    * It is Python, we are ``bash``.
    * It has a strict value restriction turned on (analogous to having ``ARG_RESTRICT_VALUES([no-option-all])`` in every script) that `can't be switched off <...>`_.

  * Argbash says:

    * We handle the boolean options better.
    * We have the :ref:`awesome wrapping functionality <argbash_wrap>`.

* ``bash`` --- ``shflags``: The ``bash`` framework for argument parsing: https://github.com/kward/shflags

  * Pros:

    * It works great on Linux.

  * Cons:

    * Doesn't work with Windows ``bash``
    * Doesn't support long options on OSX.

  * Argbash says:

    * We work the same on all platforms that have ``bash``.

* ``getopt``: Eternal utility for parsing command-line.
  This is what powers ``shflags``.

  * Pros:

    * The GNU version can work with long and short optional arguments.

  * Cons:

    * Its use is `discouraged <http://bash.cumulonim.biz/BashFAQ(2f)035.html#getopts>`_ --- it seems to have some issues, you still need to deal with positional arguments by other means.

* ``getopts``: ``bash`` builtin for parsing command-line.

  * Pros:

    * Being included with ``bash``, it behaves the same on all platforms.

  * Cons:

    * Supports only short optional arguments.

  * Argbash says:

    * ``argbash>=2.7.0`` can generate code that uses ``getopts`` in the :ref:`POSIX mode <posix>`, so there is no reason any longer to write that code manually.

.. _easy_options:

* ``EasyOptions``: ``Ruby`` utility with a ``bash`` interface as well as its pure ``bash`` implementation: https://github.com/renatosilva/easyoptions

  * Pros:

    * Very simple to use.
    * Very elegant.

  * Cons:

    * You have to distribute ``easyoptions.sh`` with your script.
    * The library itself provides only very basic functionality.
    * The project does not seem to have any tests (as of 07/2016).

  * Argbash says:

    * We have more of nice features.
    * We offer an option to produce battery-included scripts.
    * Our declarations as not so elegant, but they are not bad either.
    * The parsing part of the script generated by ``Argbash`` is only as complex as necessary.

* ``bash-modules`` - module ``argument``: ``bash-modules`` aims to become a standard ``bash`` framework and comes with an argument-parsing treat: https://github.com/vlisivka/bash-modules

  * Pros:

    * Seems to have nice features.

  * Cons:

    * ``bash-modules`` have to be available at run-time to run the script.
    * The documentation is poor (as of 07/2016).

  * Argbash says:

    * We have good documentation with examples.
    * We offer an option to produce battery-included scripts.

* ``docopt``: Umbrella project of parsing code modules for various languages. The interface is based on help messages: http://docopt.org/
  The shell interface is called `docopts <https://github.com/docopt/docopts>`_ and it is implemented as a standalone executable (in fact a Python script) that consumes the help message of the script it is used in, passed arguments, and exposes collected values via environmental variables.

  * Pros:

    * The help message as an interface is convenient.

  * Cons:

    * You need ``docopts`` installed in every environment where you run scripts that use it.

  * Argbash says:

    * Argbash is :ref:`compatible with docopt <docopt_output>` --- when using Argbash, you can go the ``docopt`` way whenever you want .

Learning resources
------------------

Do you want to write the argument-parsing part of your script yourself or you want to improve ``Argbash``?
Then read through this list of high-quality learning resources!

* Best practices in argument parsing: http://www.shelldorado.com/goodcoding/cmdargs.html
  Don't miss the list of short options and their common meaning!

* StackOverflow thread about argument parsing: http://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
  It was mainly this thread which inspired ``Argbash``.
  There are plenty of recipes and suggestions available.
  If you are a happy user of ``Argbash``, consider upvoting `the answer that promotes it <http://stackoverflow.com/a/38297066/592892>`_ since more people know ``Argbash``, the better for them.

* Argument parsing for dummies: http://wiki.bash-hackers.org/scripting/posparams
  A short and nice-looking introduction with all basics covered (wiki).

* The `POSIX conventions <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html>`_ --- the reason why ``getopts`` are still mentioned in bash learning resources.
