Package Your Python Code as a CLI
summary
Shows exactly how to turn a Python script into a CLI: copy code, pick arguments, read from stdin/stdout, add a shebang, chmod +x and put the file on PATH, then optionally replace sys.argv with argparse or Typer. Demonstrates a greet_simple example, explains piping and streams, and uses sys.argv → argparse → Typer for progressively richer interfaces. Covers making standalone tools with PEP 723 + UV for self-contained scripts and highlights autogenerated help, virtualenv-per-script behavior, and practical interface design.
AI-written summary · about
chapters (8)
- 0:00Packaging Python as CLI
- 2:52Python CLI tools
- 11:28Scripts to CLI tools
- 35:43Designing CLI interfaces
- 54:13Six steps to executable script
- 1:04:56Advanced argparse features
- 1:17:55Typer and PEP 723
- 1:25:13CLI tools best practices
related talks
33mUpgrading Python CLIs From Scripts to Interactive Tools
30mHow to give your Python code to someone else
27mHow to Write a Great Command Line Application
31mHow to give your Python code to someone else
36mCLI applications & TDD: Never write scripts again
37mLet's Make Better Command Line Applications
25mThe Hitchhiker's Guide to CLIs in Python
01h 00mplac: more than just another command-line arguments parser
