pub struct Clier<T, R> {
pub args: Argv,
/* private fields */
}Expand description
Clier is the main struct for the framework
Fields§
§args: ArgvParsed arguments from the command line
Implementations§
Source§impl Clier<HasMeta, Runnable>
impl Clier<HasMeta, Runnable>
Sourcepub fn run(self) -> ExitCode
pub fn run(self) -> ExitCode
.
Examples found in repository?
examples/framework.rs (line 22)
3fn main() {
4 let clier_builder = Clier::parse().meta(CliMeta {
5 name: "example-clier".into(),
6 usage: Some("[command]".into()),
7 description: "testing".into(),
8 version: Some("0.0.0".into()),
9 });
10
11 let app = clier_builder.runnable(vec![Commands::Collection(CmdCollection {
12 meta: CmdMeta::new("testing", "testing"),
13 children: Box::from([Commands::Command {
14 meta: CmdMeta::new("testchild", "testing"),
15 handler: |_| {
16 println!("hello");
17 ExitCode(0)
18 },
19 }]),
20 })]);
21
22 app.run();
23}Source§impl Clier<HasMeta, NotRunnable>
impl Clier<HasMeta, NotRunnable>
Sourcepub fn runnable(self, cmds: Vec<Commands>) -> Clier<HasMeta, Runnable>
pub fn runnable(self, cmds: Vec<Commands>) -> Clier<HasMeta, Runnable>
TODO
Examples found in repository?
examples/framework.rs (lines 11-20)
3fn main() {
4 let clier_builder = Clier::parse().meta(CliMeta {
5 name: "example-clier".into(),
6 usage: Some("[command]".into()),
7 description: "testing".into(),
8 version: Some("0.0.0".into()),
9 });
10
11 let app = clier_builder.runnable(vec![Commands::Collection(CmdCollection {
12 meta: CmdMeta::new("testing", "testing"),
13 children: Box::from([Commands::Command {
14 meta: CmdMeta::new("testchild", "testing"),
15 handler: |_| {
16 println!("hello");
17 ExitCode(0)
18 },
19 }]),
20 })]);
21
22 app.run();
23}Source§impl Clier<MissingMeta, NotRunnable>
impl Clier<MissingMeta, NotRunnable>
Sourcepub fn meta(self, meta: CliMeta) -> Clier<HasMeta, NotRunnable>
pub fn meta(self, meta: CliMeta) -> Clier<HasMeta, NotRunnable>
.
Examples found in repository?
examples/framework.rs (lines 4-9)
3fn main() {
4 let clier_builder = Clier::parse().meta(CliMeta {
5 name: "example-clier".into(),
6 usage: Some("[command]".into()),
7 description: "testing".into(),
8 version: Some("0.0.0".into()),
9 });
10
11 let app = clier_builder.runnable(vec![Commands::Collection(CmdCollection {
12 meta: CmdMeta::new("testing", "testing"),
13 children: Box::from([Commands::Command {
14 meta: CmdMeta::new("testchild", "testing"),
15 handler: |_| {
16 println!("hello");
17 ExitCode(0)
18 },
19 }]),
20 })]);
21
22 app.run();
23}Sourcepub fn parse() -> Clier<MissingMeta, NotRunnable>
pub fn parse() -> Clier<MissingMeta, NotRunnable>
Create a new Clier instance and parsing
Examples found in repository?
examples/framework.rs (line 4)
3fn main() {
4 let clier_builder = Clier::parse().meta(CliMeta {
5 name: "example-clier".into(),
6 usage: Some("[command]".into()),
7 description: "testing".into(),
8 version: Some("0.0.0".into()),
9 });
10
11 let app = clier_builder.runnable(vec![Commands::Collection(CmdCollection {
12 meta: CmdMeta::new("testing", "testing"),
13 children: Box::from([Commands::Command {
14 meta: CmdMeta::new("testchild", "testing"),
15 handler: |_| {
16 println!("hello");
17 ExitCode(0)
18 },
19 }]),
20 })]);
21
22 app.run();
23}Sourcepub fn with_args(args: &[String]) -> Clier<MissingMeta, NotRunnable>
pub fn with_args(args: &[String]) -> Clier<MissingMeta, NotRunnable>
Creating a new Clier instance with custom arguments
Examples found in repository?
examples/with_args.rs (line 9)
6fn main() {
7 let raw_args = args().collect::<Vec<String>>();
8 let raw_args = &raw_args[1..];
9 let args = Clier::with_args(raw_args);
10
11 // Try changing 'String' to 'bool', or 'i64'
12 let example_hook: Result<String, clier::hooks::FlagError> =
13 use_flag("testing", Some('t'), &args).try_into();
14
15 // Everything to the right of '--'
16 let raw = use_double_dash(&args);
17
18 println!("flag testing: {:#?}\neverything after '--': {:?}", example_hook, raw);
19}Trait Implementations§
Auto Trait Implementations§
impl<T, R> Freeze for Clier<T, R>
impl<T, R> RefUnwindSafe for Clier<T, R>where
T: RefUnwindSafe,
R: RefUnwindSafe,
impl<T, R> Send for Clier<T, R>
impl<T, R> Sync for Clier<T, R>
impl<T, R> Unpin for Clier<T, R>
impl<T, R> UnwindSafe for Clier<T, R>where
T: UnwindSafe,
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more