soph_console/support/
command.rsuse crate::{
support::STYLES,
traits::{ApplicationTrait, CommandTrait},
Handler,
};
use clap::ArgMatches;
use std::sync::Arc;
pub struct Command {
inner: clap::Command,
handler: Handler,
}
impl Command {
pub fn new<A, T>() -> Self
where
A: ApplicationTrait,
T: CommandTrait,
{
Self {
inner: T::command().styles(STYLES),
handler: Arc::new(|arg_matches: ArgMatches| T::handle::<A>(arg_matches)),
}
}
pub fn name(&self) -> &str {
self.inner.get_name()
}
pub fn command(&self) -> &clap::Command {
&self.inner
}
pub fn handler(&self) -> &Handler {
&self.handler
}
}