respec / HSPsquared

Hydrologic Simulation Program Python (HSPsquared)
GNU Affero General Public License v3.0
43 stars 17 forks source link

Alternate CLI library to `mando`? #76

Open aufdenkampe opened 2 years ago

aufdenkampe commented 2 years ago

With PR #65 & #75, @timcera introduced some nice Command Line Interface (CLI) features to HSP2. To do so, he used the Mando library.

Unfortunately, mando hasn't been updated since 2017 or tested on Python 3.9, and we'll be wanting to migrate to Python 3.9 in the next round of work. We'll likely want to select and implement an alternative Python CLI library.

Here are few posts that I found on the topic:

timcera commented 2 years ago

I use mando for all my projects and test my projects using Python 3.7, 3.8, and 3.9. Not direct testing, but no problems in my projects.

Mando is the best, IMO. One of it's best features is building the help text from the docstring. Surprisingly this is rare. The only library that comes close is clize (https://pypi.org/project/clize/) however clize requires Sphinx formatted docstrings, whereas mando can use Sphinx, Numpy, or Google formatted docstrings.

If clize is more acceptable, it might be close to a drop in replacement, after converting the Numpy formatted docstrings to Sphinx format.

aufdenkampe commented 2 years ago

@timcera, thanks for that extra info on mando. It's helpful to know that you have it working with Python 3.9!

Thanks also for pointing us to clize. We'll take a look!

aufdenkampe commented 1 year ago

I just came across the click (Command Line Interface Creation Kit) library, recommended in a series of posts on Hypermodern Python (with examples at https://github.com/cjolowicz/hypermodern-python).

click is also recommended over other libraries by https://realpython.com/comparing-python-command-line-parsing-libraries-argparse-docopt-click/#my-recomendation

timcera commented 1 year ago

I have forked mando to cltoolbox (https://pypi.org/search/?q=cltoolbox and https://github.com/timcera/cltoolbox). The only substantial differences are automatic detection of the docstring type (Sphinx RST, Numpy, or Google) and dropping support for Python 2.