Summary
This chapter took you through the most popular library for building modern CLIs – Cobra – and its partner library for configuration – Viper. The Cobra package was explained in detail and the CLI’s usage with examples was also described. We went through examples to take you through generating your initial application code with the Cobra CLI, adding new commands and modifying the scaffolding, to autogenerate useful help and man pages. Viper, as a configuration tool that fits perfectly alongside Cobra, was also described, along with many of its options, in detail.
In the next chapter, we’ll discuss how to handle input to a CLI – whether it’s text in the form of commands, arguments, or flags, or the control characters that allow you to quit out of a terminal dashboard. We’ll also discuss different ways this input is processed and how to output results back to the user.