oof: impl fmt::Display for Flag

This commit is contained in:
Vinícius Miguel 2021-04-07 23:12:30 -03:00
parent c08eb91632
commit 5cca3c42e4

View File

@ -29,6 +29,15 @@ pub struct Flag {
pub takes_value: bool,
}
impl std::fmt::Display for Flag {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.short {
Some(short_flag) => write!(f, "-{}, --{}", short_flag, self.long),
None => write!(f, "--{}", self.long),
}
}
}
impl Flag {
pub fn long(name: &'static str) -> Self {
Self {