Flags vs settings¶
RTB scaffolds two different ways for a tool to take input, and the scaffolder has a distinct verb for each. They are not interchangeable — picking the right one is about where the value comes from and how long it lives.
flag— a clap argument the user types on the command line for one invocation (transient).setting— a typed field onAppConfigthe tool reads from its layered config: config file, environment, or a CLI override (persistent).
At a glance¶
flag |
setting |
|
|---|---|---|
| Scaffolder verb | rtb generate flag / rtb remove flag |
rtb generate setting / rtb remove setting |
| Lives in | src/commands/<cmd>.rs (a clap Arg) |
src/main.rs (AppConfig field) |
| Scope | one command | whole tool |
| Source | typed on the CLI per run | config file → env (MYTOOL_<NAME>) → CLI override |
| Lifetime | transient (this invocation) | persistent (configured once) |
| Marker region | // rtb:flags-begin/-end |
// rtb:settings-begin/-end |
When to use which¶
- Reach for a flag when the value is an action parameter the user
decides at call time:
deploy --region eu,build --release,--dry-run. - Reach for a setting when the value is configuration the user sets once and the tool reuses: an API endpoint, a default output directory, a retry count. These come from the figment layers (defaults → file → env → CLI) — see Configuration.
A value can legitimately be both: expose a setting for the configured
default and a flag that overrides it for one run. RTB keeps them as two
explicit pieces rather than fusing them.
Why two concepts (the gtb contrast)¶
Go Tool Base (cobra +
viper) fuses these into a single persistent flag — a CLI flag bound to
a dynamic config bag. RTB deliberately diverges: figment config is a
typed AppConfig struct, not a GetString("key") bag (see
why-rtb). So a clap flag and a config field are
genuinely different things in RTB, and the scaffolder names them
separately. remove flag is the gtb-parity verb; setting is
RTB-native.
The
settingverb was namedconfig-fieldbefore cli-bin v0.6.0. The rename (and its inverseremove setting) is covered by2026-06-22-scaffolder-setting-verb.