|
@@ -180,13 +180,13 @@ impl<O: CLIObject> InterfaceVerb<O> {
|
|
relation,
|
|
relation,
|
|
remote_keys,
|
|
remote_keys,
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ },
|
|
"create" => InterfaceVerb::Create(
|
|
"create" => InterfaceVerb::Create(
|
|
<O::CreateParameters as clap::FromArgMatches>::from_arg_matches(matches)?,
|
|
<O::CreateParameters as clap::FromArgMatches>::from_arg_matches(matches)?,
|
|
),
|
|
),
|
|
"delete" => {
|
|
"delete" => {
|
|
InterfaceVerb::Delete(collect_keys::<O, IC>(matches, ValueRole::BaseTarget))
|
|
InterfaceVerb::Delete(collect_keys::<O, IC>(matches, ValueRole::BaseTarget))
|
|
- }
|
|
|
|
|
|
+ },
|
|
"detach" => {
|
|
"detach" => {
|
|
let (local_keys, relation, remote_keys) = Self::parse_attachment::<IC>(matches)?;
|
|
let (local_keys, relation, remote_keys) = Self::parse_attachment::<IC>(matches)?;
|
|
InterfaceVerb::Detach {
|
|
InterfaceVerb::Detach {
|
|
@@ -194,18 +194,18 @@ impl<O: CLIObject> InterfaceVerb<O> {
|
|
relation,
|
|
relation,
|
|
remote_keys,
|
|
remote_keys,
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ },
|
|
"list" => InterfaceVerb::ListAll,
|
|
"list" => InterfaceVerb::ListAll,
|
|
"inspect" => {
|
|
"inspect" => {
|
|
InterfaceVerb::Inspect(collect_keys::<O, IC>(matches, ValueRole::BaseTarget))
|
|
InterfaceVerb::Inspect(collect_keys::<O, IC>(matches, ValueRole::BaseTarget))
|
|
- }
|
|
|
|
|
|
+ },
|
|
cmd => {
|
|
cmd => {
|
|
if <O::ExtraCommands>::has_subcommand(cmd) {
|
|
if <O::ExtraCommands>::has_subcommand(cmd) {
|
|
InterfaceVerb::Extra(<O::ExtraCommands>::from_arg_matches(parent_matches)?)
|
|
InterfaceVerb::Extra(<O::ExtraCommands>::from_arg_matches(parent_matches)?)
|
|
} else {
|
|
} else {
|
|
unreachable!()
|
|
unreachable!()
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ },
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -235,7 +235,7 @@ impl<'l, Error: CLIError, OE: Entity> Attacher<'l, Error, OE> {
|
|
} else {
|
|
} else {
|
|
self.err = map.disconnect_from(obj.id()).err().map(Into::into);
|
|
self.err = map.disconnect_from(obj.id()).err().map(Into::into);
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ },
|
|
Ok(None) => {
|
|
Ok(None) => {
|
|
self.err = Some(Error::no_such_entity(
|
|
self.err = Some(Error::no_such_entity(
|
|
E::entity_name(),
|
|
E::entity_name(),
|
|
@@ -246,10 +246,10 @@ impl<'l, Error: CLIError, OE: Entity> Attacher<'l, Error, OE> {
|
|
.unwrap()
|
|
.unwrap()
|
|
.to_string(),
|
|
.to_string(),
|
|
));
|
|
));
|
|
- }
|
|
|
|
|
|
+ },
|
|
Err(e) => {
|
|
Err(e) => {
|
|
self.err = Some(e.into());
|
|
self.err = Some(e.into());
|
|
- }
|
|
|
|
|
|
+ },
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -371,10 +371,10 @@ impl<O: CLIObject, IC: InterfaceCustomization> ClapInterface<O, IC> {
|
|
if let Some(err) = attacher.err {
|
|
if let Some(err) = attacher.err {
|
|
return Err(err);
|
|
return Err(err);
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ },
|
|
InterfaceVerb::Create(params) => {
|
|
InterfaceVerb::Create(params) => {
|
|
insert_ctx.insert(O::create_from_params(data, params)?)?;
|
|
insert_ctx.insert(O::create_from_params(data, params)?)?;
|
|
- }
|
|
|
|
|
|
+ },
|
|
InterfaceVerb::Delete(keys) => {
|
|
InterfaceVerb::Delete(keys) => {
|
|
let keys = EntityKey::to_string_vec(keys, ic);
|
|
let keys = EntityKey::to_string_vec(keys, ic);
|
|
query_ctx
|
|
query_ctx
|
|
@@ -382,7 +382,7 @@ impl<O: CLIObject, IC: InterfaceCustomization> ClapInterface<O, IC> {
|
|
UniqueList::<O>::build_equivalent(keys.iter().map(String::as_str)).unwrap(),
|
|
UniqueList::<O>::build_equivalent(keys.iter().map(String::as_str)).unwrap(),
|
|
)
|
|
)
|
|
.delete()?;
|
|
.delete()?;
|
|
- }
|
|
|
|
|
|
+ },
|
|
InterfaceVerb::Detach {
|
|
InterfaceVerb::Detach {
|
|
local_keys,
|
|
local_keys,
|
|
relation,
|
|
relation,
|
|
@@ -418,7 +418,7 @@ impl<O: CLIObject, IC: InterfaceCustomization> ClapInterface<O, IC> {
|
|
if let Some(err) = attacher.err {
|
|
if let Some(err) = attacher.err {
|
|
return Err(err);
|
|
return Err(err);
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ },
|
|
InterfaceVerb::ListAll => {
|
|
InterfaceVerb::ListAll => {
|
|
println!(
|
|
println!(
|
|
"Listing all {}(s): ({})",
|
|
"Listing all {}(s): ({})",
|
|
@@ -428,7 +428,7 @@ impl<O: CLIObject, IC: InterfaceCustomization> ClapInterface<O, IC> {
|
|
for obj in query_ctx.get()?.into_iter() {
|
|
for obj in query_ctx.get()?.into_iter() {
|
|
println!(" - {}", obj.shortname());
|
|
println!(" - {}", obj.shortname());
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ },
|
|
InterfaceVerb::Inspect(keys) => {
|
|
InterfaceVerb::Inspect(keys) => {
|
|
let keys = EntityKey::to_string_vec(keys, ic);
|
|
let keys = EntityKey::to_string_vec(keys, ic);
|
|
let obj = query_ctx
|
|
let obj = query_ctx
|
|
@@ -491,10 +491,10 @@ impl<O: CLIObject, IC: InterfaceCustomization> ClapInterface<O, IC> {
|
|
}
|
|
}
|
|
|
|
|
|
obj.accept_part_visitor_ref(&mut RelationFieldWalker(Default::default()));
|
|
obj.accept_part_visitor_ref(&mut RelationFieldWalker(Default::default()));
|
|
- }
|
|
|
|
|
|
+ },
|
|
InterfaceVerb::Extra(extra) => {
|
|
InterfaceVerb::Extra(extra) => {
|
|
O::run_extra_command(data, extra, query_ctx, insert_ctx)?;
|
|
O::run_extra_command(data, extra, query_ctx, insert_ctx)?;
|
|
- }
|
|
|
|
|
|
+ },
|
|
}
|
|
}
|
|
Ok(())
|
|
Ok(())
|
|
}
|
|
}
|