Separate business logic from CLI handling to make code reusable as a library module.
Accepts explicit parameters with defaults. Contains all business logic. Returns results, raises exceptions. Never calls sys.exit(). Can be imported and called from other modules.
Handles argument parsing only. Converts CLI strings to appropriate types. Calls main() with parsed arguments. Catches expected exceptions and converts to exit codes. All sys.exit() calls contained here. Provides user-friendly error messages to stderr.
Same code works as both script and library. Defaults defined once in main() signature. Easy to test (no sys.exit() to mock). Clear separation of concerns. Unexpected exceptions show full traceback automatically.