Skip to main content
Every task in a bakebook is a Typer command. That is what gives you typed arguments, per-task --help, and shell completion for free (bake --install-completion). There are two patterns, depending on whether you define the task before or after instantiating the bakebook:

Pattern 1: On the class

Use @command() on class methods, and access the context through self.ctx:

Pattern 2: On the instance

Use @bakebook.command() on standalone functions, and access the context through bakebook.ctx:

Decorator options

@command() accepts all Typer options: name, help, deprecated, and so on. Rename a task or document it without touching its function:

Typed arguments

Task parameters become typed CLI options. Defaults carry over, and --help documents itself:
Use Annotated with typer.Option for custom flags:
Arguments are coerced and validated before your task runs, so a bad value fails at the CLI with a clear error instead of halfway through your task. See Context for running commands inside tasks, and Bakebook for the class that holds them.