Defining Your CLI

This section covers the fundamental patterns for structuring your command-line application with goopt. You will learn how to define flags, organize commands, and handle positional arguments using goopt’s flexible struct-first and programmatic APIs.

Choose a topic to begin:

  1. Struct Tags Reference: A quick reference guide to all available goopt:"..." struct tags.
  2. Command Patterns: Learn different ways to organize your commands and subcommands, from simple flat structures to complex nested hierarchies.
  3. Flag Patterns: Explore patterns for organizing your flags, including namespacing with nested structs and creating reusable flag groups.
  4. Positional Arguments: A detailed guide on defining and using arguments that rely on their position in the command line.
  5. Command Callbacks: Learn how to add behavior to your commands and access parsed data from your logic.

Table of contents