meta_args
Shared
--metadata / --metadata-json flag parsing for create/update commands.fn build_metadata
pub fn build_metadata(
base: Option<Value>,
pairs: &[String],
json_blobs: &[String],
) -> Result<Option<Value>, Error>Build a metadata Value::Object from repeated --metadata key=value pairs and
--metadata-json '<json-object>' strings, layered on top of an optional base.
Scalar pairs are inserted first (with dot-path support and scalar inference);
--metadata-json objects are then merged shallow on top so they can override.
Returns None when no inputs are provided and no base exists.
| Parameter | Type | Description |
|---|---|---|
base |
Option<Value> | the metadata to start from, such as the entity’s current metadata; a non-object is replaced |
pairs |
&[String] | the --metadata values, each key=value with a dot-delimited key |
json_blobs |
&[String] | the --metadata-json values, each a JSON object |
| returns | Result<Option<Value>, Error> | base unchanged when there are no pairs and no blobs; otherwise the merged object. Error::Argument for a pair with no =, a key path that is too deep, or a blob that is not a JSON object. |