use std::fmt::{Display, Formatter, Result};
use derive_getters::Getters;
#[derive(Debug)]
pub struct SubCommandName;
impl<'scmd> SubCommandName {
pub const LIST: &'scmd str = "list";
pub const OPEN: &'scmd str = "open";
pub const REMOVE: &'scmd str = "remove";
pub const VARIANT: &'scmd str = "variant";
}
#[derive(Debug)]
pub struct OptionalCommandName;
impl<'ocmd> OptionalCommandName {
pub const DEBUG: &'ocmd str = "debug";
}
#[derive(Debug, Clone, Default, Getters)]
pub struct Argument {
value: Option<String>,
name: Option<String>,
}
impl Display for Argument {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(
f,
"Argument Name: {:?}\nValue: {:?}",
self.name(),
self.value()
)
}
}
#[derive(Debug, Getters)]
pub struct ActiveCommand {
command: String,
arg: Argument,
}
impl Display for ActiveCommand {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(f, "Active subcommand: {}\n{}", self.command(), self.arg())
}
}
impl ActiveCommand {
pub fn new(command: &str, arg: Argument) -> Self {
Self {
command: String::from(command),
arg,
}
}
}