mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-07 03:55:28 +00:00
oof: impl fmt::Display for Flag
This commit is contained in:
parent
c08eb91632
commit
5cca3c42e4
@ -29,6 +29,15 @@ pub struct Flag {
|
|||||||
pub takes_value: bool,
|
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 {
|
impl Flag {
|
||||||
pub fn long(name: &'static str) -> Self {
|
pub fn long(name: &'static str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user