Generating Command Completion and Documentation

Learn how to add new subcommands to the tool to generate command completion and documentation.

Two features that improve our user experience are command completion and documentation. Command completion guides the user by providing contextual suggestions when they press the “Tab” key. Documentation instructs users by providing additional information, context, and examples about using the application.

Adding subcommands

Let’s add two new subcommands to our tool, allowing the users to generate command completion and documentation for it. We start with the command completion subcommand completion. We use the Cobra generator again to add this subcommand to our application:

Get hands-on with 1200+ tech skills courses.