Skip to content

Latest commit

 

History

History
31 lines (21 loc) · 1.85 KB

File metadata and controls

31 lines (21 loc) · 1.85 KB

🎤 Interview Q&A - Build opsctl CLI Foundation

1. What problem does argparse solve in a CLI project?

It provides a structured way to define commands, flags, help output, and validation rules so the CLI behaves consistently and is easier to maintain.

2. Why were subparsers useful in this lab?

Subparsers let the tool expose separate workflows such as status, deploy, and config while sharing one common entry point.

3. Why is an entry point in setup.py important?

It exposes the package as a console command so the tool can be run as opsctl after installation instead of calling a Python module manually.

4. What was the purpose of the version module?

It centralized package metadata like version, description, and author so those values can be reused across the CLI and packaging logic.

5. Why did the status command support both text and JSON output?

Text output is friendly for operators reading the terminal, while JSON output is better for automation, scripting, and integrations.

6. How was configuration persistence handled?

The CLI stored configuration values in a JSON file under the user home directory so values survive across command executions.

7. Why was validate_environment kept in a helper module?

Keeping shared validation logic in a helper module reduces duplication and makes command modules simpler.

8. What benefit comes from returning exit codes from the command handlers?

Exit codes make the CLI easier to automate because scripts can detect success, failure, or interruption reliably.

9. Why is help output considered part of CLI quality?

Clear help text reduces operator mistakes, speeds onboarding, and makes the tool self-documenting.

10. What would be a sensible next improvement for this CLI?

Adding logging, tests, richer output formatting, and real backend integrations would make the tool more production-ready.