pub struct PropMeta {Show 23 fields
pub key: &'static str,
pub ty: Ty,
pub default: Option<Const>,
pub merge: Merge,
pub scope: Scope,
pub parse: Option<Parser>,
pub envs: &'static [&'static str],
pub deprecated_envs: &'static [&'static str],
pub cli: &'static [&'static str],
pub bindings: &'static [(&'static str, &'static str)],
pub choices: &'static [Const],
pub hide: bool,
pub deprecated: Option<&'static str>,
pub renamed_to: Option<&'static str>,
pub aliases: &'static [&'static str],
pub optional: Option<bool>,
pub help: Option<&'static str>,
pub long_help: Option<&'static str>,
pub default_note: Option<&'static str>,
pub since: Option<&'static str>,
pub deprecated_warn_at: Option<&'static str>,
pub deprecated_remove_at: Option<&'static str>,
pub examples: &'static [&'static str],
}Expand description
What one setting is.
Every field is const-constructible, so a generated registry is a static with no
initializer to run.
Fields§
§key: &'static strThe dotted key, which is also what a config file and config set call it.
ty: Ty§default: Option<Const>The value when no layer supplies one.
merge: Merge§scope: Scope§parse: Option<Parser>How to split a single string into several values, when a layer hands over text.
envs: &'static [&'static str]Environment variables that set it, highest precedence first.
deprecated_envs: &'static [&'static str]Deprecated environment aliases, consulted after every current name.
cli: &'static [&'static str]The flags that set it, as the spec’s cli node declares them: ["--jobs", "-j"].
Documentation for the most part — an explanation that lists the environment variables and not
the flag is answering half the question a user asked. It is also what a generated test can
hold the executable binding against, since a spec that declares --jobs and a CLI that
never reads it into the setting is the shape of hk’s thirteen dead sources.cli lines.
bindings: &'static [(&'static str, &'static str)]Its keys in sources usage does not know about: [("git", "hk.jobs")]. A custom layer
asks the registry for its own kind and iterates what it finds, which is the whole
mechanism behind hk’s git and pkl layers and aube’s .npmrc.
choices: &'static [Const]The only values this setting accepts, when it says.
Empty means anything the type allows. Declared in the spec as choice nodes, where they
already reach the docs, the JSON schema and completions — and, until this, nothing that
resolved a value, so a CLI documenting three allowed values accepted a fourth in silence.
hide: boolKept out of documentation and completions. Still settable.
deprecated: Option<&'static str>Why not to use this any more.
renamed_to: Option<&'static str>The setting that replaces this one. A value found under the old key is folded into the new one at the same precedence, with a warning.
aliases: &'static [&'static str]Equivalent keys accepted without a rename warning.
optional: Option<bool>An explicit optionality contract, when the declaration does not use inference.
help: Option<&'static str>§long_help: Option<&'static str>§default_note: Option<&'static str>Prose beside the default, for a default the registry cannot hold — one computed at runtime, or one whose literal alone would mislead (“0 = one per core”).
since: Option<&'static str>The release that introduced this setting, when the declaration says.
deprecated_warn_at: Option<&'static str>The CLI version that starts warning about a deprecated setting, and the one after which configured values for it are ignored.
deprecated_remove_at: Option<&'static str>§examples: &'static [&'static str]Values worth showing a reader, verbatim.
Implementations§
Source§impl PropMeta
impl PropMeta
Sourcepub fn refuses<'v>(&self, value: &'v Value) -> Option<&'v Value>
pub fn refuses<'v>(&self, value: &'v Value) -> Option<&'v Value>
The first value here that this setting does not allow, if there is one.
A collection is checked item by item, because choices on a list<string> mean each item is
one of them — the same rule usage g json-schema follows, which puts the enum on every value
position rather than on the container. Returning the offender rather than a bool is what lets
the warning quote the item that is wrong instead of the whole list it was in.