...

/

Finalizing the Cobra-generated Application

Finalizing the Cobra-generated Application

Now, let's finalize our demo applications and use the Cobra generator's configuration file.

Using the Cobra generator configuration file

When generating a lot of commands you often have to repeat the same arguments like license and author. Cobra provides a configuration file where you can set all these options just once. The default configuration file is: ~/.cobra.yaml. Here is an example configuration file for the choices we made for the calculator application:

author: Gigi
license: none

Adding pre-run and post-run Hooks

When you build larger applications, there are often various cross-cutting concerns like logging and instrumentation that you may want to perform for all commands. For example, run some ...