[][src]Struct climake::CliMake

pub struct CliMake<'cli, 'a> {
    pub args: &'cli [Argument<'a>],
    pub description: Option<&'static str>,
    pub version: Option<String>,
}

Main holder structure of entire climake library, used to create new CLIs.

It is reccomended this be called something simple like cli for ease of use as this is the most used part of climake.

Examples

This example panics
use climake::{Argument, CliMake, DataType};

fn main() {
    let args = &[
        Argument::new(
            &['o'],
            &["output", "out"],
            Some("Example output arg"),
            DataType::Files,
        ).unwrap(),
        Argument::new(
            &['a', 'b', 'c'],
            &[],
            Some("Alphabet!"),
            DataType::None,
        ).unwrap(),
    ];

    let cli = CliMake::new(args, Some("A showcase CLI to demonstrate climake"), None).unwrap();

    println!("Args used: {:#?}", cli.parse());
}

Fields

args: &'cli [Argument<'a>]

Arguments to use for CLI instance

description: Option<&'static str>

Optional description of CLI

version: Option<String>

Optional version of CLI/program

Finding your crate's version

You may use the following snippet (taken from clap) to fetch your cargo version

pub fn crate_version() -> String {
    format!(
        "{}.{}.{}{}",
        env!("CARGO_PKG_VERSION_MAJOR"),
        env!("CARGO_PKG_VERSION_MINOR"),
        env!("CARGO_PKG_VERSION_PATCH"),
        option_env!("CARGO_PKG_VERSION_PRE").unwrap_or("")
    )
}

Implementations

impl<'cli, 'a> CliMake<'cli, 'a>[src]

pub fn new(
    args: &'cli [Argument<'a>],
    description: Option<&'static str>,
    version: Option<String>
) -> Result<Self, CLIError>
[src]

Shortcut to making a CliMake structure, the main entrypoint into building a CLI with climake

pub fn header_msg(&self) -> String[src]

Header message to be used above help or errors to show the CLI has been at least successfully initiated and to show basic info about the program

pub fn help_msg(&self) -> String[src]

Overall help for built CLI, displays header and every arg using Argument::pretty_help

pub fn specific_help(&self, arg: &Argument<'_>) -> String[src]

Produces a Argument::pretty_help with CLI's header to be used for arg-specific help messages

pub fn parse(&self) -> Vec<UsedArg<'_>>[src]

Parses arguments and returns all UsedArgs

Trait Implementations

impl<'cli, 'a> Clone for CliMake<'cli, 'a>[src]

impl<'cli, 'a> Debug for CliMake<'cli, 'a>[src]

impl<'cli, 'a> PartialEq<CliMake<'cli, 'a>> for CliMake<'cli, 'a>[src]

impl<'cli, 'a> StructuralPartialEq for CliMake<'cli, 'a>[src]

Auto Trait Implementations

impl<'cli, 'a> RefUnwindSafe for CliMake<'cli, 'a>

impl<'cli, 'a> Send for CliMake<'cli, 'a>

impl<'cli, 'a> Sync for CliMake<'cli, 'a>

impl<'cli, 'a> Unpin for CliMake<'cli, 'a> where
    'a: 'cli, 

impl<'cli, 'a> UnwindSafe for CliMake<'cli, 'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.