External Library Options for CLIs
Here are resources for more information about external libraries options:
00:00 Along with the standard library, there are a variety of external libraries that are available to help you build command line interfaces. In this lesson, I’ll tell you a little bit about a few of those.
Here are some examples of external libraries for command line interfaces. I’m going to give a demonstration in my own code of the
click module and also the Python Prompt Toolkit, but all of these are really incredible and useful libraries for command line interfaces.
click, I would say, is the most powerful of the bunch. It’s known for being really modular and has a decorator-based syntax.
This is used by some really large and influential open-source Python projects like Flask and Black. Some other options are
docopt, which is great if you like to simply write out a detailed spec which will generate the whole command line interface for you, and then there’s also
clize, which I personally really enjoy because it’s super simple to use. You just write out some docstrings underneath the function, and that generates the command line interface for you. Python Prompt Toolkit is a little bit more of an alternative to a traditional command line interface because it has aspects of a graphical user interface as well, so that’s a pretty cool way to start thinking about some of the ways that a command line interface can kind of expand out of just the pure plain text version that I’ve shown you so far.
An important thing to remember for all of these external libraries is that you’ll have to install them in some way before you can use them. In most cases, that will be as simple as using
pip in your terminal and writing something like
pip install click, or
pip install clize, but in rare cases it might turn out to be a little bit more complicated.
Become a Member to join the conversation.