appentry 0.1.4

A minimalist command-line argument parsing library
Documentation

appentry

version status

A minimalist command-line argument parsing library

Usage

cargo add appentry

Hello World:

#[appentry::appentry]
fn add(x: i32, y: i32) -> anyhow::Result<()> {
    println!("{}", x + y);
    Ok(())
}

fn main() -> anyhow::Result<()> {
    appentry::dispatch(true)?;
    Ok(())
}

/*
$ myapp --help
Usage: appentry.exe [Options]
Options:
    -x|--x <i32>
    -y|--y <i32>

$ myapp -x 1 -y 2
3
*/

Multiple methods & async & docs:

/// Print the application version
///
/// # Arguments
///
/// This function takes no arguments
#[appentry::appentry]
fn version() {
    println!(
        "{} {}",
        std::env!("CARGO_PKG_NAME"),
        std::env!("CARGO_PKG_VERSION")
    );
}

/// Add two numbers
///
/// # Arguments
///
/// * `x` - The first number to add
/// * `y` - The second number to add
#[appentry::appentry]
async fn add(x: i32, y: i32) -> anyhow::Result<()> {
    println!("{}", x + y);
    Ok(())
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    appentry::dispatch_async(true).await?;
    Ok(())
}

/*
$ myapp --help
Desc:  Add two numbers
Usage: appentry.exe -a|--add [Options]
Options:
    -x|--x <i32> The first number to add
    -y|--y <i32> The second number to add

Desc:  Print the application version
Usage: appentry.exe -v|--version

$ myapp --version
myapp 0.1.0
*/