meta

Generic meta actions: show, get, set and unset an entity’s JSON metadata.

fn bare

source

pub async fn bare<E: HasMetadata>(
    context: &AppContext,
    raw_id: &str,
    output: &json::Flags,
) -> Result<(), Error>

Display the full metadata blob for an entity.

Parameter Type Description
context &AppContext the application context: settings, store and current project
raw_id &str the entity’s ID or a unique prefix of it
output &json::Flags the output mode: normal, --json, --quiet or --raw
returns Result<(), Error> Ok(()) once the metadata is printed, or the error from resolving or loading the entity.

fn get

source

pub async fn get<E: HasMetadata>(
    context: &AppContext,
    raw_id: &str,
    path: &str,
    output: &json::Flags,
) -> Result<(), Error>

Resolve an entity and print a single metadata value at a dot-delimited path.

Parameter Type Description
context &AppContext the application context: settings, store and current project
raw_id &str the entity’s ID or a unique prefix of it
path &str the dot-delimited key path, such as review.owner
output &json::Flags the output mode: normal, --json, --quiet or --raw
returns Result<(), Error> Ok(()) once the value is printed, Error::MetaKeyNotFound when path holds no value, or the error from resolving or loading the entity.

fn set

source

pub async fn set<E: HasMetadata>(
    context: &AppContext,
    raw_id: &str,
    path: &str,
    value: &str,
    as_json: bool,
    output: &json::Flags,
) -> Result<(), Error>

Set a metadata value on an entity at a dot-delimited path within a recorded transaction.

Parameter Type Description
context &AppContext the application context: settings, store and current project
raw_id &str the entity’s ID or a unique prefix of it
path &str the dot-delimited key path; missing or non-object values on the way become objects
value &str the value as typed on the command line
as_json bool parse value as JSON; otherwise it becomes a boolean, a number or a string
output &json::Flags the output mode: normal, --json, --quiet or --raw
returns Result<(), Error> Ok(()) once the entity is updated and printed, Error::MetaKeyNotFound when path has more segments than the store allows, a JSON error when as_json is set and value is not JSON, or the error from resolving, loading or saving the entity.

fn unset

source

pub async fn unset<E: HasMetadata>(
    context: &AppContext,
    raw_id: &str,
    path: &str,
    output: &json::Flags,
) -> Result<(), Error>

Remove a metadata value from an entity at a dot-delimited path within a recorded transaction.

Parameter Type Description
context &AppContext the application context: settings, store and current project
raw_id &str the entity’s ID or a unique prefix of it
path &str the dot-delimited key path to remove
output &json::Flags the output mode: normal, --json, --quiet or --raw
returns Result<(), Error> Ok(()) once the entity is updated and printed, Error::MetaKeyNotFound when path holds no value, or the error from resolving, loading or saving the entity.

fn render_normal

source

fn render_normal(metadata: &Value) -> String

Render metadata as a themed field list, one dot-path for each leaf value.

Parameter Type Description
metadata &Value the metadata to render
returns String The field list, or (no metadata) when there is nothing to show.

fn render_raw

source

fn render_raw(metadata: &Value) -> String

Render metadata as plain path=value lines for scripts.

Parameter Type Description
metadata &Value the metadata to render
returns String One path=value line for each leaf value, joined with newlines; empty when there is none.