Skip to main content
Options in Runegraft are declared with the opt helper. They stay close to your function signatures, so type hints and defaults map directly to your CLI help text.

Adding options

  • Short and long flags are defined together: opt("--dry-run", "-n", default=False, ...).
  • Defaults show up in generated help output automatically.
  • Type hints (bool, str, int, etc.) are enforced and reflected in the usage string.

Choices and validation

Provide a set of allowed values to restrict input:
When a user passes an invalid value, Runegraft prints a clear error and shows the valid choices.

Pairing with routes

Options layer cleanly on top of your route patterns. Keep positional arguments in the route (e.g., <env:str>) and reserve options for optional behavior. Combine options with Type Converters to accept richer input like URLs or JSON blobs.