Clier

Struct Clier 

Source
pub struct Clier<T, R> {
    pub args: Argv,
    /* private fields */
}
Expand description

Clier is the main struct for the framework

Fields§

§args: Argv

Parsed arguments from the command line

Implementations§

Source§

impl Clier<HasMeta, Runnable>

Source

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>

Source

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>

Source

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}
Source

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}
Source

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§

Source§

impl<T: Clone, R: Clone> Clone for Clier<T, R>

Source§

fn clone(&self) -> Clier<T, R>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, R: Debug> Debug for Clier<T, R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default, R: Default> Default for Clier<T, R>

Source§

fn default() -> Clier<T, R>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T, R> Freeze for Clier<T, R>
where T: Freeze, R: Freeze,

§

impl<T, R> RefUnwindSafe for Clier<T, R>

§

impl<T, R> Send for Clier<T, R>
where T: Send, R: Send,

§

impl<T, R> Sync for Clier<T, R>
where T: Sync, R: Sync,

§

impl<T, R> Unpin for Clier<T, R>
where T: Unpin, R: Unpin,

§

impl<T, R> UnwindSafe for Clier<T, R>
where T: UnwindSafe, R: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.