Struct celp_sdk::util::celp_app::CelpApp

source ·
pub struct CelpApp {
    pub app_name: String,
    /* private fields */
}
Expand description

CelpApp: Thin wrapper around clap::Command. Allows creating a command line application

Fields§

§app_name: String

Implementations§

source§

impl CelpApp

source

pub fn new(app_name: &'static str) -> Self

Creates a new CelpApp instantiation with the desired name

§Arguments
  • app_name - The application name
§Example
use celp_sdk::util::celp_app::CelpApp;

let app = CelpApp::new("test");
source

pub fn ignore_errors(self, yes: bool) -> Self

source

pub fn disable_help_flag(self, yes: bool) -> Self

source

pub fn allow_missing_positional(self, yes: bool) -> Self

source

pub fn arg(self, arg: Arg) -> Self

source

pub fn init_logger(self, yes: bool) -> Self

Ensures the logger is initialised (true by default)

§Arguments
  • yes - Whether to initialise the logging or not
§Example
use celp_sdk::util::celp_app::CelpApp;

let matches = CelpApp::new("test")
    .init_logger(false)
    .parse();
source

pub fn publish_app_info(self, app_info: AppInfo) -> Self

Ensures the app version is published to the broker

§Arguments
  • app_info - The application info to publish
§Examples
use celp_sdk::util::celp_app::{build_app_info, CelpApp};

let app_info = build_app_info("1.0.0").unwrap();

let matches = CelpApp::new("test")
    .publish_app_info(app_info)
    .parse();
source

pub fn get_matches(self) -> ArgMatches

Parses the command line parameters and propagates the matches

§Example
use celp_sdk::util::celp_app::{build_app_info, Arg, CelpApp};

let app_info = build_app_info("1.0.0").unwrap();

let matches = CelpApp::new("test")
    .publish_app_info(app_info)
    .arg(
        Arg::new("test")
        .short('t')
        .long("test")
        .help("Testing an additional variable")
        .required(true)
    )
    .get_matches();

if let Some(t) = matches.get_one::<String>("test") {
    println!("Test argument was set to \"{}\"", t);
}
source

pub fn parse(self)

Just parse the command line parameters

§Example
use celp_sdk::util::celp_app::CelpApp;

let matches = CelpApp::new("test")
    .parse();

Auto Trait Implementations§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.