This workshop is designed to teach developers the complete process of designing, building, and testing a modern Command Line Interface (CLI) application. Students will learn how to build a lightweight CLI application from scratch and then explore the benefits of using the Cobra framework to increase development proficiency. They will also gain insights into building applications for different operating systems, using build tags for feature sets, and releasing and distributing applications across Unix, Linux, and Windows operating systems via popular package managers such as Homebrew and GoFish.
If you want to follow along with my presentation on your own computer, please visit the slides online here.
- Golang
- VSCode or any other IDE.
- Cobra CLI
- GoReleaser
Also, please make sure to have a GitHub account for Session 4.
- Example 1 - Build a CLI using the Go standard library “hello world!”
- Example 2 - Create a CLI that takes in a file input, reads in the file, then outputs the content
- Example 3 - Run a couple commands and to show command (verb), argument (noun), and flag (adjective)
- Example 4 - Modify the CLI to validate that the input is of JSON format.
- Example 5 - Modify the CLI to output in YAML format
- Example 6 - Refactor code to use modularization
- Example 7 - Convert flat structure to group by context
- Example 8 - Pass an invalid file, watch an error returned. Rewrite error to use clear and concise language.
- Example 9 - Add flags to customize output, silence flag, or output to specify the name of an output file.
- Example 10 - Create a simple CLI with cobra-cli
- Example 11 - Create a convert command with three flags: filename, silence, and output
- Example 12 - Nested commands
- Example 13 - Global, local, and required flags
- Example 14 - Error handling
- Example 15 - Autogeneration of man pages
- Example 16 - Intelligent suggestions
- Example 17 - Write test for Cobra CLI command
- Example 18 - Show how changing code breaks test
- Example 19 - Create new store command
- Example 20 - Create request to https://jsonbin.io/
- Example 21 - Handle response
- Example 22 - Add survey
- Example 24 - Create command and create termindal dashboard layout
- Example 25 - Add components to the terminal dashboard layout
- Example 26 - Add styling to the terminal dashboard layout
- Example 27 - Building with tags
- Example 28 - Compiling with GOOS/GOARCH
- Example 29 - Test on a different platform with Docker
- Examples 30-36 - Distributing with Homebrew
Click here to view all videos from the presentation.