reactive_graph/client/instances/entities/args/
set_property.rs

1use crate::client::error::CommandError;
2use crate::client::error::CommandError::NotFound;
3use crate::client::instances::properties::args::parse_json;
4use clap::Args;
5use serde_json::Value;
6use uuid::Uuid;
7
8/// CLI argument which identifies a reactive instance by its id.
9#[derive(Args, Debug, Clone)]
10pub(crate) struct SetPropertyArgs {
11    /// The id of the reactive instance.
12    pub id: Uuid,
13
14    /// The name of the property.
15    pub name: String,
16
17    /// The new JSON value of the property.
18    ///
19    /// 'true' is boolean true, '"true"' is the string "true"
20    #[clap(value_parser = parse_json)]
21    pub value: Value,
22}
23
24impl SetPropertyArgs {
25    pub fn id_not_found(&self) -> CommandError {
26        NotFound(format!("The instance with the id {} was not found", &self.id))
27    }
28
29    pub fn property_not_found(&self) -> CommandError {
30        NotFound(format!("The instance with the id {} has no property {}", &self.id, &self.name))
31    }
32}