Replace manual sys.argv handling with Python's built-in argparse module to define named arguments, optional flags, restricted choices, and auto-generated --help output ā the pattern behind every professional Python CLI tool.
Create a directory for this lesson, activate the shared virtual environment, and copy `deploy_check.py` from Lesson 102 as the starting point. Lesson 103 evolves that script from raw sys.argv to a fully-specified argparse CLI.
mkdir -p ~/devops-python/lesson-103cd ~/devops-python/lesson-103cp ~/devops-python/lesson-102/deploy_check.py .source ~/devops-python/lesson-101/devops-env/bin/activatecat deploy_check.pyCopying deploy_check.py from Lesson 102 gives you the shebang, chmod +x history, and the sys.argv guard that you will now replace.
The argparse module is part of the Python standard library ā no pip install needed, just import argparse.
Your terminal prompt shows (devops-env). cat deploy_check.py shows the 8-step version from Lesson 102: shebang on line 1, len(sys.argv) < 2 guard, environment = sys.argv[1], and the status header print block.