Skip to main content
In this lesson we build several compact CLI utilities to demonstrate rapid prototyping and testing of command-line tools in three languages: Python, Go, and C++. The hands-on examples include:
  • A Python project-structure generator that scaffolds basic HTML and Vue projects into dist/.
  • A Go CLI that converts data/contacts.csv to JSON and supports a --limit flag.
  • A C++ password generator that compiles on macOS via a Makefile.
A presentation slide titled "Building CLI Tools" on a light background with a dark curved panel on the right displaying the word "Demo."
Overview
  • Python: quick scripting for scaffolding and automation.
  • Go: compact, statically compiled utilities for file processing.
  • C++: high-performance or system-level binaries for sensitive tasks (e.g., cryptographic-grade password generation).
When running Python scripts locally, consider using a virtual environment (python3 -m venv .venv and source .venv/bin/activate) to avoid polluting system packages.
Project generator (Python)
  • Goal: scaffold a small project into dist/ — either a minimal HTML site or a tiny Vue app.
  • Output: a folder such as dist/my-html-site containing index.html, style.css, and scripts.js (or a minimal set for Vue).
The generator is straightforward and focused on clarity: map template filenames to content and write them into the target folder. This pattern is easy to extend with new templates or additional file types. Example minimal startup of the generator (excerpt from project_generator.py):
Quick run examples:
Result
  • The generated HTML boilerplate can be opened in a browser. The page includes a hero/title and a button wired via scripts.js to demonstrate a tiny interactive feature.
A browser screenshot of a simple HTML project page with a large "Welcome to My HTML Project" header and a centered card reading "Hello, World!" with a "Click Me" button. The developer's code editor is visible in the background.
Vue project
  • The same generator can scaffold a minimal Vue app (files like index.html, style.css, app.js).
  • The sample Vue output demonstrates reactive state: a counter and a simple todo list to illustrate how the scaffold can help you start a small SPA quickly.
A screenshot of a browser showing "My Vue.js App" with a centered card containing a counter (Count: 2) and Increment/Decrement/Reset buttons, plus a "Simple Todo" section with two todo items and Remove buttons. The app is displayed on a purple gradient background with a code editor visible behind the window.
CLI utility: CSV → JSON (Go)
  • Purpose: convert data/contacts.csv to JSON and optionally limit the number of output records with --limit (or -limit).
  • Design: robust error handling, sensible defaults, and a small data model (Contact) to shape JSON output.
This example assumes the first CSV row is a header: id,first_name,last_name,job_title,email. If your CSV differs, adjust the parsing logic accordingly.
Example main.go (concise and robust):
Minimal go.mod:
Build & run examples:
Typical JSON output (abbreviated):
CLI utility: Strong password generator (C++)
  • Purpose: generate cryptographically strong passwords with flags for length, count, and whether to include symbols.
  • Approach: use std::random_device and std::mt19937 for secure seeding and a uniform distribution over the chosen character set.
Example passgen.cpp (excerpt):
Makefile (macOS-compatible):
Build & run:
Summary and where these CLI tools fit
  • CLI tools accelerate local automation: file conversion, data processing, and scripted maintenance tasks.
  • They integrate well into CI/CD for repeatable tasks like formatters, validators, and transforms.
  • Quick-tier summary:
Further reading and references These short examples show how small, well-scoped CLI utilities in different languages can automate repetitive workflows and become dependable parts of your development and deployment pipeline. Thank you for reading this lesson.

Watch Video