Skip to content

Latest commit

 

History

History
88 lines (75 loc) · 3.21 KB

File metadata and controls

88 lines (75 loc) · 3.21 KB

🧪 Lab 01 - Build opsctl CLI Foundation

🎯 Objective

Designed a modular Python CLI tool with subcommands, argument parsing, config persistence, and editable installation.

📚 Prerequisites

  • Basic understanding of Python programming
  • Familiarity with command-line interfaces
  • Knowledge of Git version control
  • Experience with Linux terminal commands
  • Understanding of function definitions and argument parsing

🖥️ Lab Environment

  • Operating System: Ubuntu 24.04 LTS cloud lab environment
  • Primary User: toor
  • Python Runtime: Python 3.12.x in a virtual environment

✅ Learning Objectives Covered

  • Design and implement a structured CLI tool architecture
  • Parse and handle command-line arguments effectively
  • Create modular command implementations
  • Implement help documentation and version management
  • Apply best practices for CLI tool development

🧩 Task Overview

This lab was completed through the following high-level activities:

  • Task 1: Design CLI Structure and Argument Handling
  • Step 1: Create Version Module
  • Step 2: Implement Core CLI Framework
  • Step 3: Implement Command Modules
  • Step 4: Create Utility Functions
  • Step 5: Create Setup Configuration
  • Task 2: Implement and Test CLI Commands
  • Step 1: Complete the Implementation

📁 Repository Structure

lab01-build-opsctl-cli-foundation/
├── README.md
├── commands.sh
├── output.txt
├── interview_qna.md
├── troubleshooting.md
└── project/
    README.md
    opsctl/__init__.py
    opsctl/cli.py
    opsctl/commands/__init__.py
    opsctl/commands/config.py
    opsctl/commands/deploy.py
    opsctl/commands/status.py
    opsctl/utils/__init__.py
    opsctl/utils/helpers.py
    opsctl/version.py
    setup.py

🔍 Verification & Validation

  • Test version flag
  • Test help output
  • Test status command
  • Test config commands
  • Test deploy command
  • Test invalid environment
  • Test missing required arguments
  • Test non-existent config key

🧠 What I Learned

  • How to structure a Python CLI package with clear command modules.
  • How argparse subparsers simplify multi-command tools.
  • How to persist lightweight configuration data in JSON.
  • How to combine human-readable and JSON output formats for operational tools.

🌍 Why This Matters

CLI tools are still a core interface for DevOps and platform engineering work. A clean command hierarchy, sensible help output, and repeatable installation flow make operational tooling easier to maintain and safer to use.

🚀 Real-World Applications

  • Internal DevOps utilities for deployment orchestration.
  • Platform support tools for environment checks and status reporting.
  • Developer-facing CLIs for configuration inspection and automation workflows.

📌 Result

Built and validated an installable opsctl CLI with status, deploy, and config subcommands.

🏁 Conclusion

This lab strengthened my hands-on foundation in build opsctl cli foundation and produced a clean set of project files, command history, execution output, interview notes, and troubleshooting guidance for portfolio use.

All code, commands, outputs, and support material used for this lab are organized in this folder for traceability and GitHub documentation readiness.