Code


Part 3: Under the Hood dives into the inner workings of CLI application development, with real-world examples written in Go. This section of the website provides complete, working code samples—along with compiling instructions—so readers can quickly get hands-on with the concepts. It also includes examples from Part 4: The Modern CLI, which explores patterns, practices, and design strategies in greater depth. Together, these examples bring the book’s ideas to life and support deeper learning through practical application.

ExamplePurpose
IP ToolA simple CLI that demonstrates the use of flags and switches while interacting with an external API to retrieve the public IP address of the host machine.
Cobra CLIA straightforward yet fully functional example showcasing the object-command model implemented using the Cobra package. It demonstrates how to structure commands, flags, and subcommands following modern CLI design principles.
LoggerDemonstrates configurable logging using the ZeroLog library, with support for adjustable severity levels to suit various runtime environments.
Exit CodeA minimal example that demonstrates how to return meaningful exit codes from a command-line application to signal success or failure.
Task CLIThis example was designed to demonstrate object return values and structured exit codes, as discussed in the chapter “Put On Your PowerShell® Hat.” It illustrates how to build CLIs that integrate cleanly with scripting environments like PowerShell.
Output CLIThis example can be examined to better understand default formatting and using a flag to specify various alternate formats.
REPL CLIThis example showcases a Read-Eval-Print Loop (REPL) style interface. It echoes user input and includes basic built-in commands such as HELP and EXIT, providing a simple foundation for interactive CLI applications.
LanguagesThis page highlights key language differences—such as readability and type systems—through side-by-side “Hello, World” examples written in Python, Rust, and Go.

Additional relevant topics that did not make the book can be found in this site’s Overflow section.