CLI applications & TDD: Never write scripts again
summary
Argues that throwaway scripts should become test-driven CLI apps and shows a real refactor: a messy workflow script is turned into a package with proper if __name__ == '__main__' guard, cli-test-helpers is used to run commands and simulate argv and env for functional tests, and examples use argparse, click, docopt side-by-side. Covers packaging with entry points, running the installed CLI in a venv, and driving coverage toward 100% so behavior and deployment are verifiable.
AI-written summary · about
chapters (8)
- 0:00Introduction to testing
- 5:02Agenda and goals
- 6:26Problems with raw scripts
- 9:15Refactoring and testing
- 19:23CLI library options
- 25:55Challenges in CLI testing
- 29:13Testing strategy and tools
- 32:26Deployment and conclusion
related talks
31mStop writing scripts! CLI applications with TDD
32mTest-drive the development of your command-line applications
27mHow to Write a Great Command Line Application
16mBuilding an interactive CLI app in Elixir
37mLet's Make Better Command Line Applications
30mCLI Tools for All the Things
38mFlorian Rappl: Testing CLI Utilities
29mBuilding Nice Command Line Interfaces — A Look Beyond the stdlib
