Chapter 7: Writing Command-Line Tooling
Visit any DevOps engineer and you will find their screens filled with terminals executing Command-Line Interface (CLI) applications.
As a DevOps engineer, we don't want to only use applications that others have made for us; we want to be able to write our own CLI applications. These applications might communicate to various systems via REST or gRPC, as we discussed in our previous chapter. Or you might want to execute various applications and run their output through custom processing. An application might even set up a development environment and kick off a test cycle for a new release.
Whatever your use case, you will need to use some common packages to help you manage the application's input and output processing.
In this chapter, you will learn how to use the flag
and os
packages to write simple CLI applications. For more complex applications, you will learn how to use the Cobra package. These skills, combined with the...