-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
either with `--color no` or when output is piped
- Loading branch information
Showing
6 changed files
with
86 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
use { | ||
argh::FromArgs, | ||
std::path::PathBuf, | ||
}; | ||
|
||
#[derive(FromArgs)] | ||
/// List your filesystems. | ||
/// | ||
/// All units are SI. | ||
/// | ||
/// Source at https://github.com/Canop/lfs | ||
pub struct Args { | ||
/// print the version | ||
#[argh(switch, short = 'v')] | ||
pub version: bool, | ||
|
||
#[argh(option, default = "Default::default()")] | ||
/// color: 'yes', 'no' or 'auto' (auto should be good in most cases) | ||
pub color: BoolArg, | ||
|
||
/// whether to show all mount points | ||
#[argh(switch, short = 'a')] | ||
pub all: bool, | ||
|
||
/// output as JSON | ||
#[argh(switch, short = 'j')] | ||
pub json: bool, | ||
|
||
#[argh(positional)] | ||
/// if a path is provided, only the device holding this path will be shown | ||
pub path: Option<PathBuf>, | ||
} | ||
|
||
/// An optional boolean for use in Argh | ||
#[derive(Debug, Clone, Copy, Default)] | ||
pub struct BoolArg(Option<bool>); | ||
|
||
impl BoolArg { | ||
pub fn value(self) -> Option<bool> { | ||
self.0 | ||
} | ||
} | ||
|
||
impl argh::FromArgValue for BoolArg { | ||
fn from_arg_value(value: &str) -> Result<Self, String> { | ||
match value.to_lowercase().as_ref() { | ||
"auto" => Ok(BoolArg(None)), | ||
"yes" => Ok(BoolArg(Some(true))), | ||
"no" => Ok(BoolArg(Some(false))), | ||
_ => Err(format!("Illegal value: {:?}", value)), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters