use ffsend_api::url::Url;
use clap::ArgMatches;
use super::Matcher;
use crate::cmd::arg::{ArgOwner, ArgPassword, ArgUrl, CmdArgOption};
pub struct InfoMatcher<'a> {
matches: &'a ArgMatches<'a>,
}
impl<'a: 'b, 'b> InfoMatcher<'a> {
pub fn url(&'a self) -> Url {
ArgUrl::value(self.matches)
}
pub fn owner(&'a self) -> Option<String> {
ArgOwner::value(self.matches).map(|token| token.to_owned())
}
pub fn password(&'a self) -> Option<String> {
ArgPassword::value(self.matches)
}
}
impl<'a> Matcher<'a> for InfoMatcher<'a> {
fn with(matches: &'a ArgMatches) -> Option<Self> {
matches
.subcommand_matches("info")
.map(|matches| InfoMatcher { matches })
}
}