reactive_graph_client/client/instances/relations/args/
set_property.rs

1use crate::client::error::CommandError;
2use crate::client::error::CommandError::NotFound;
3use crate::client::instances::properties::args::PropertyInstanceArgs;
4use crate::client::instances::relations::args::id::RelationInstanceIdArgs;
5use clap::Args;
6use reactive_graph_graph::RelationInstanceId;
7
8/// CLI argument for searching relation instances.
9#[derive(Args, Debug, Clone)]
10pub(crate) struct SetPropertyArgs {
11    /// The id of the relation instance.
12    #[clap(flatten)]
13    pub id: RelationInstanceIdArgs,
14
15    #[clap(flatten)]
16    pub property_instance: PropertyInstanceArgs,
17}
18
19impl SetPropertyArgs {
20    pub fn not_found(&self) -> CommandError {
21        self.id.not_found()
22    }
23
24    pub fn property_not_found(&self) -> CommandError {
25        let id: RelationInstanceId = self.into();
26        NotFound(format!("The relation instance with the id {} has no property {}", id, &self.property_instance.property_name))
27    }
28}
29
30impl From<&SetPropertyArgs> for RelationInstanceId {
31    fn from(args: &SetPropertyArgs) -> Self {
32        RelationInstanceId::from(&args.id)
33    }
34}