Skip to main content

Module coerce

Module coerce 

Source
Expand description

Coerce CLI string arguments to Value.

Functions§

coerce_scalar
Shape-based coercion with no type context: an explicit prefix wins, otherwise null/true/false/integer/float/JSON are recognized by shape, falling back to String. Used where no target type is available (e.g. keyed-list fields without a default template).
coerce_scalar_typed
Coerce a single CLI string toward the type already present at the target (existing) — never by guessing the string’s shape. An explicit prefix always wins, and "null" always clears. When the target is a typed scalar the string is parsed into that type (falling back to String so the consumer’s deserialize step produces a precise error); when the target is absent/null or a container, only an explicit JSON literal is structured, otherwise it stays a String.
coerce_values
Coerce a slice of CLI values to Value via shape-based coerce_scalar.
coerce_values_typed
Type-directed coercion of a CLI value slice toward the type at existing.