~/talk

How to Write a Great Command Line Application

Talkat PyCon US 2026 · 2026-05-13..05-19· [python, developer-experience]
name:Dan Craig
links:none on file
slides:none on file

Shows concrete patterns: build a CLI using argparse for the 90% case, parse types at the edge, wrap logic in a testable main that returns an int and a do(...) that accepts keyword args via vars(ns), handle file inputs without relying on deprecated filetype (Python 3.14), fix buffering and suppress broken pipe on pipelines, map -v count to logging levels, and ship a single-file script with a shebang or the uv shebang trick

AI-written summary · about

  1. 0:00Command line apps intro
  2. 1:09How command line arguments work in Python
  3. 4:59Simple comparison script
  4. 7:05Type conversion in args
  5. 8:49Testable CLI with main
  6. 10:10Efficient file reading
  7. 12:59File inputs with argparse
  8. 15:23Optional args & output
  9. 16:27Business logic abstraction
  10. 18:54Continuous output with generators
  11. 20:41Broken pipes & interruptions
  12. 22:06Logging verbosity control
  13. 23:09Third-party CLI libraries
  14. 23:50Shebang lines for scripts
  15. 25:15CLI best practices summary
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.