pub struct Schema {
pub args: Vec<ArgSpec>,
pub options: BTreeMap<String, OptionSpec>,
pub strict: bool,
pub description: Option<String>,
pub commands: BTreeMap<String, Schema>,
}Expand description
The schema declared inline in a sub-command’s fdl.yaml. Maps 1:1 to
what <entry> --fdl-schema will later emit as JSON.
deny_unknown_fields also applies to the --fdl-schema probe JSON:
a schema emitted by a NEWER flodl-cli-macros than this fdl knows
fails to parse rather than silently dropping the unknown field, and
the probe layer falls back to the inline yml schema (or none) —
help always renders (see schema_cache).
Fields§
§args: Vec<ArgSpec>§options: BTreeMap<String, OptionSpec>§strict: boolWhen true, the fdl layer rejects options not declared in the schema before the sub-command’s entry ever runs. Two validation points:
- Load time — preset
options:maps are checked against the enclosingschema.options(seesuper::validation::validate_presets_strict). A typo likeoptions: { batchsize: 32 }when the schema declaresbatch-sizeis a loud load error. - Dispatch time — the user’s extra argv tail is tokenized
against the schema (see
super::validation::validate_tail). Unknown flags error out with a “did you mean” suggestion instead of being silently forwarded.
Validation NOT gated by strict — always-on for declared
items, so positive assertions from the schema always hold:
choices:on options: the user’s value and any preset YAML value must be in the list.choices:on positional args: the user’s value must be in the list (when strict is off, this may mis-fire if unknown flags push orphan values into positional slots — opt into strict for clean positional handling).
strict is purely about unknown options/args, not about
validating declared contracts.
description: Option<String>One-line human description of this node. Usually unset for the root
of a flat schema (help banners come from the binary’s struct doc);
for a child under Self::commands it carries the subcommand’s
summary (the enum variant’s doc-comment), rendered in the parent
--help COMMANDS list.
commands: BTreeMap<String, Schema>Sub-command tree. Empty for a leaf — the common case: a single
#[derive(FdlArgs)] struct. Non-empty for a variant-shaped CLI
(#[derive(FdlArgs)] on an enum of newtype variants), where each key
is a subcommand name and each value is that subcommand’s own schema.
A node is either a leaf (args / options) or a branch
(commands), never both — enforced by validate_schema. The shape
mirrors the recursive commands: map already used by
CommandConfig/super::ProjectConfig at the yaml layer.