Chapter 15: Further Reading

Annotated Bibliography

1. Python argparse Documentation

URL: https://docs.python.org/3/library/argparse.html The official Python documentation for argparse is comprehensive and includes a tutorial section. While dense, it covers every feature including advanced patterns like parent parsers, custom actions, and argument groups. Start with the tutorial, then use the reference when you need specific features.

2. Click Documentation

URL: https://click.palletsprojects.com/ Author: Armin Ronacher / Pallets Project The official click documentation is exceptionally well-written, with a quickstart guide, detailed API reference, and advanced patterns section. Pay special attention to the "Testing Click Applications" section, which covers CliRunner -- a feature that makes click-based tools significantly easier to test than argparse-based ones.

3. Rich Documentation

URL: https://rich.readthedocs.io/ Author: Will McGuinness (textualize) The documentation for the rich library covers progress bars, tables, trees, syntax highlighting, markdown rendering, and more. The "Progress" section is particularly relevant for CLI tools. The library also includes rich.logging.RichHandler, which produces beautifully formatted log output for development.

4. Python Packaging User Guide

URL: https://packaging.python.org/ Author: Python Packaging Authority (PyPA) This is the authoritative guide to Python packaging. The "Packaging Python Projects" tutorial walks through creating pyproject.toml, building distributions, and uploading to PyPI. The "Guides" section covers advanced topics like entry points, dependency management, and choosing a build backend.

5. The Linux Command Line by William Shotts

Publisher: No Starch Press, 2nd Edition (2019) While not Python-specific, this book provides essential context for CLI development. Understanding how the shell works -- pipes, redirection, exit codes, signals, environment variables -- is fundamental to building tools that integrate well with the Unix ecosystem. Free online at linuxcommand.org.

6. Fluent Python by Luciano Ramalho

Publisher: O'Reilly Media, 2nd Edition (2022) Chapters on file I/O, context managers, and generators are directly applicable to CLI tool development. The sections on pathlib, iterators, and the with statement provide the Python foundations for the file processing patterns covered in this chapter.

7. Typer Documentation

URL: https://typer.tiangolo.com/ Author: Sebastian Ramirez Typer is a modern CLI framework built on top of click that uses Python type hints to define arguments and options. If you like click's approach but want even less boilerplate, typer is worth exploring. It automatically generates help text from function signatures and docstrings.

8. Twelve-Factor App -- Config Section

URL: https://12factor.net/config Author: Adam Wiggins While written for web applications, the twelve-factor methodology's section on configuration applies directly to CLI tools. The principle that configuration should be stored in the environment (not in code) is the foundation for the environment variable layer in our configuration hierarchy.

9. Python Logging HOWTO

URL: https://docs.python.org/3/howto/logging.html The official Python logging tutorial covers basic and advanced logging configuration. The "Advanced Logging Tutorial" section explains handlers, formatters, filters, and the logger hierarchy. This is essential reading for understanding how RotatingFileHandler and custom formatters work.

10. GNU Coding Standards -- Command-Line Interfaces

URL: https://www.gnu.org/prep/standards/html_node/Command_002dLine-Interfaces.html This section of the GNU coding standards defines conventions for command-line interfaces that have been followed by Unix tools for decades. Understanding these conventions (short and long option names, -- to end options, exit codes) helps you build tools that feel natural to experienced command-line users.

11. Building Command Line Applications with Click (Real Python Tutorial)

URL: https://realpython.com/python-click/ A thorough tutorial that walks through building a click-based CLI application step by step. Covers command groups, parameter types, file arguments, callbacks, and testing. Particularly useful for understanding click's context system and how to share state between commands.

12. Questionary Documentation

URL: https://questionary.readthedocs.io/ Author: Thomas M. Klich Questionary is a Python library for building interactive command-line prompts. It provides text input, password input, confirmation, selection lists, checkboxes, and autocomplete. It is useful for building setup wizards and interactive configuration tools.

13. Serious Python by Julien Danjou

Publisher: No Starch Press (2018) Chapter 5 covers distributing Python software, including setuptools, entry points, and wheel packaging. Chapter 6 discusses testing strategies that are directly applicable to CLI tools. The book provides practical, opinionated advice from an experienced open-source maintainer.

14. sysexits.h -- Standard Exit Codes

URL: https://man.freebsd.org/cgi/man.cgi?query=sysexits The BSD sysexits.h header defines standardized exit codes (64-78) for common error categories: usage errors (64), data format errors (65), OS errors (71), I/O errors (74), and others. While not universally adopted, these codes provide a well-thought-out framework for defining your own exit code scheme.

15. XDG Base Directory Specification

URL: https://specifications.freedesktop.org/basedir-spec/latest/ The formal specification for where applications should store configuration ($XDG_CONFIG_HOME`), data (`$XDG_DATA_HOME), cache ($XDG_CACHE_HOME), and runtime files. Following this specification keeps user home directories clean and makes your tool a good citizen on Unix systems.