diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /vendor/xflags/README.md | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/xflags/README.md')
-rw-r--r-- | vendor/xflags/README.md | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/vendor/xflags/README.md b/vendor/xflags/README.md new file mode 100644 index 000000000..bfebfb0c8 --- /dev/null +++ b/vendor/xflags/README.md @@ -0,0 +1,49 @@ +[![API reference](https://docs.rs/once_cell/badge.svg)](https://docs.rs/xflags/) + +# xflags + +Moderately simple command line arguments parsing: + +```rust +mod flags { + use std::path::PathBuf; + + xflags::xflags! { + src "./examples/basic.rs" + + cmd my-command + required path: PathBuf + { + optional -v, --verbose + } + } + + // generated start + // The following code is generated by `xflags` macro. + // Run `env UPDATE_XFLAGS=1 cargo build` to regenerate. + #[derive(Debug)] + pub struct MyCommand { + pub path: PathBuf, + + pub verbose: bool, + } + + impl MyCommand { + pub const HELP: &'static str = Self::HELP_; + + pub fn from_env() -> xflags::Result<Self> { + Self::from_env_() + } + + pub fn from_vec(args: Vec<std::ffi::OsString>) -> xflags::Result<Self> { + Self::from_vec_(args) + } + } + // generated end +} + +fn main() { + let flags = flags::MyCommand::from_env(); + println!("{:#?}", flags); +} +``` |