simple click


πŸŽ„This post has fully grown

cli tools are super handy and easy to add to your python libraries to supercharge them. Even if your library is not a cli tool there are a number of things that a cli can do to your library.

Example Ideas

Things a cli can do to enhance your library.

πŸ†š print version πŸ•Ά print readme πŸ“ print changelog πŸ“ƒ print config ✏ change config πŸ‘©β€πŸŽ“ run a tutorial πŸ— scaffold a project with cookiecutter

πŸ–± Click

Click is the most popular python cli tool framework for python. There are others, some old, some new comers that make take the crown. For now Click is the gold standard if you want to make a powerful cli quickly. If you are dependency conscious and dont need a lot of tooling, use argparse.

Project Structure

└── simple_click


    # simple_click/
    import click

    __version__ = "1.0.0"
    def cli():

    def version():
        """prints project version"""

    if __name__ == '__main__':


For our simpleclick library __init__.py__ can be left empty. It is here purely to signify that simpleclick is a library. It is likely that you will import other modules here that need to reside at the top level of your library api, your cli does not need to be at the top of of your api.


πŸšͺ Entry Points

Entry points are the magic that make python cli tools available as their own command without having python before it or the file extension.


    from setuptools import setup, find_packages

    # this is the πŸ₯© meat of this snippet
    # simple_click is the command name
    # = simple_click is the library name
    # .cli is the file
    # :cli is the cli function
    # the second item is a shorthand alias to the main command

    entry_points = [
       "simple_click = simple_click.cli:cli",
       "scli         = simple_click.cli:cli",

        entry_points={"console_scripts": entry_points},


πŸ•Ά See it in action

See it in action

πŸ“’ Discuss

What do You wish more python libraries included in their cli? Tweet it @_waylonwalker

Tweet it @_waylonwalker

πŸ‘€ see an issue, edit this post on GitHub

If you found value in this post
and want to send a tip.

Buy Me A Coffee

tweet about this post and it will show up here.

←An IndieWeb Webring πŸ•ΈπŸ’β†’