use clap::{Arg, ArgMatches};
use super::{CmdArg, CmdArgFlag, CmdArgOption};
use crate::cmd::matcher::{MainMatcher, Matcher};
use crate::util::prompt_owner_token;
pub struct ArgOwner {}
impl CmdArg for ArgOwner {
fn name() -> &'static str {
"owner"
}
fn build<'b, 'c>() -> Arg<'b, 'c> {
Arg::with_name("owner")
.long("owner")
.short("o")
.alias("owner-token")
.value_name("TOKEN")
.min_values(0)
.max_values(1)
.help("Specify the file owner token")
}
}
impl CmdArgFlag for ArgOwner {}
impl<'a> CmdArgOption<'a> for ArgOwner {
type Value = Option<String>;
fn value<'b: 'a>(matches: &'a ArgMatches<'b>) -> Self::Value {
if !Self::is_present(matches) {
return None;
}
match Self::value_raw(matches) {
None => {}
p => return p.map(|p| p.into()),
}
let matcher_main = MainMatcher::with(matches).unwrap();
Some(prompt_owner_token(&matcher_main, false))
}
}