diff options
Diffstat (limited to 'docs/alternatives.rst')
-rw-r--r-- | docs/alternatives.rst | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/docs/alternatives.rst b/docs/alternatives.rst index 68513ff6..3587b749 100644 --- a/docs/alternatives.rst +++ b/docs/alternatives.rst @@ -5,16 +5,15 @@ Alternatives to cmd and cmd2 For programs that do not interact with the user in a continuous loop - programs that simply accept a set of arguments from the command line, return results, and do not keep the user within the program's environment - all -you need are sys_\ .argv (the command-line arguments) and optparse_ -(for parsing UNIX-style options and flags). +you need are sys_\ .argv (the command-line arguments) and argparse_ +(for parsing UNIX-style options and flags). Though some people may prefer docopt_ +or click_ to argparse_. -.. _optparse: http://docs.python.org/library/optparse.html#module-optparse +.. _sys: https://docs.python.org/3/library/sys.html +.. _argparse: https://docs.python.org/3/library/argparse.html +.. _docopt: https://pypi.python.org/pypi/docopt +.. _click: http://click.pocoo.org -.. _sys: http://docs.python.org/library/sys.html#module-sys - -.. _curses: http://docs.python.org/library/curses.html#module-curses - -.. _cmd: https://docs.python.org/3/library/cmd.html The curses_ module produces applications that interact via a plaintext terminal window, but are not limited to simple text input and output; @@ -22,29 +21,33 @@ they can paint the screen with options that are selected from using the cursor keys. However, programming a curses_-based application is not as straightforward as using cmd_. -Several packages in PyPI enable interactive command-line applications -approximately similar in concept to cmd_ applications. None of them -share cmd2's close ties to cmd, but they may be worth investigating -nonetheless. - - * CmdLoop_ - * cly_ - * CmDO_ (As of Feb. 2010, webpage is missing.) - * pycopia-CLI_ - -cmdln_, another package in PyPI, is an extension to cmd_ and, though it -doesn't retain full cmd_ compatibility, shares its basic structure with -cmd_. +.. _curses: https://docs.python.org/3/library/curses.html +.. _cmd: https://docs.python.org/3/library/cmd.html -.. _cmdln: http://pypi.python.org/pypi/cmdln +Several Python packages exist for building interactive command-line applications +approximately similar in concept to cmd_ applications. None of them +share ``cmd2``'s close ties to cmd_, but they may be worth investigating +nonetheless. Two of the most mature and full featured are: -.. _CmdLoop: http://pypi.python.org/pypi/CmdLoop + * `Python Prompt Toolkit`_ + * Click_ -.. _cly: http://pypi.python.org/pypi/cly +.. _`Python Prompt Toolkit`: https://github.com/jonathanslenders/python-prompt-toolkit -.. _CmDO: http://pypi.python.org/pypi/CmDO/0.7 +`Python Prompt Toolkit`_ is a library for building powerful interactive command lines and terminal applications in +Python. It provides a lot of advanced visual features like syntax highlighting, bottom bars, and the ability to +create fullscreen apps. -.. _pycopia-CLI: https://github.com/kdart/pycopia/tree/master/CLI +Click_ is a Python package for creating beautiful command line interfaces in a composable way with as little code as +necessary. It is more geared towards command line utilities instead of command line interpreters, but it can be used +for either. -I've found several alternatives to cmd in PyPI - CmdLoop, cly, CMdO, and pycopia. cly looks wonderful, but I haven't been able to get it working under Windows, and that's a show-stopper for many potential sqlpython users. In any case, none of the alternatives are based on cmd - they're written from scratch, which means that a cmd-based app would need complete rewriting to use them. I like sticking close to the Standard Library whenever possible. cmd2 lets you do that. +Getting a working command-interpreter application based on either `Python Prompt Toolkit`_ or Click_ requires a good +deal more effort and boilerplate code than ``cmd2``. ``cmd2`` focuses on providing an excellent out-of-the-box experience +with as many useful features as possible built in for free with as little work required on the developer's part as +possible. We believe that ``cmd2`` provides developers the easiest way to write a command-line interpreter, while +allowing a good experience for end users. If you are seeking a visually richer end-user experience and don't +mind investing more development time, we would recommend checking out `Python Prompt Toolkit`_. +In the future, we may investigate options for incorporating the usage of `Python Prompt Toolkit`_ and/or Click_ into +``cmd2`` applicaitons. |