2 unstable releases

0.2.0 Aug 4, 2023
0.1.0 Jul 8, 2023

#679 in Command-line interface

Download history 2/week @ 2023-12-18 13/week @ 2023-12-25 7/week @ 2024-01-15 19/week @ 2024-01-29 1/week @ 2024-02-12 23/week @ 2024-02-19 20/week @ 2024-02-26 10/week @ 2024-03-04 10/week @ 2024-03-11 4/week @ 2024-03-18 18/week @ 2024-03-25 31/week @ 2024-04-01

65 downloads per month
Used in 3 crates

MIT and GPL-3.0 licenses

18KB
293 lines

CLIPLY

Making command-line interfaces in Rust easy.

GitHub CI

ABOUT

Cliply is an alterantive to the popular clap library for parsing and processing command-line arguments. It is intended to be a little more friendly for people who are only just learning Rust. Enjoy!

FEATURES

  • Blazingly fast.
  • Easy to use, no drama.
  • Provides multiple options out of the box.
  • Provides a -h or --help flag out of the box.
  • Provides a -v or --version flag out of the box.

INSTALLATION

To use Cliply in your Rust project add this line to your project's Cargo.toml's [dependencies] section:

cliply = "0.2.0"

To import the library into your project's code, use this line:

use cliply::App;

To find out exactly how to use the library please read the section below.

EXAMPLE

An example of how to use Cliply's APIs in a sample app can be viewed below:

/*
CLIPLY by "Angel Dollface".
Licensed under the MIT license.
*/

/// Importing the main
/// Cliply API struct.
use cliply::App;

/// Importing the error
/// struct to handle any
/// errors.
use cliply::CliplyError;

/// Main point of
/// entry for the 
/// Rust compiler.
pub fn main() -> () {

    // Instantiating the "App" struct with the required
    // data.
    let mut my_app: App = App::new(
        &"Test App",
        &"1.0.0",
        &"Angel Dollface"
    );

    // Adding a greeting without data. Note the use of "false".
    my_app.add_arg(
        &"greet", 
        &" generic greeting for the user", 
        &"false"
    );

    // Adding a greeting with data. Note the use of "true".
    my_app.add_arg(
        &"cgreet", 
        &"custom greeting for the user", 
        &"true"
    );

    // Was the version flag used?
    if my_app.version_is() == true {
        println!("{}", my_app.version_info());
    }

    // Was the help flag used?
    else if my_app.help_is() == true {
        println!("{}", my_app.help_info());
    }

    // Was the "greet" flag used?
    else if my_app.arg_was_used(&"greet") == true {
        println!("Hello World!");
    }

    // Was the "cgreet" flag used? Note the use of the result!
    else if my_app.arg_was_used(&"cgreet") == true {
        let arg_data: Result<String, CliplyError> = my_app.get_arg_data(&"cgreet");
        match arg_data {
            Ok(x) => {
                println!("Hello, {}!", x);
            },
            Err(e) => {
                println!("{}", e.to_string());
            }
        }
    }

    // If user-supplied flags are invalid, show
    // them the app's help message.
    else {
        println!("{}", my_app.help_info());
    }
    
}

If you would like to read detailed documentation, you can do so by visiting this link.

CHANGELOG

Version 0.1.0

  • Initial release.
  • Upload to GitHub.

Version 0.2.0

  • Updated documentation.
  • Updated the version of the coutils crate.

NOTE

  • Cliply by Alexander Abraham a.k.a. "Angel Dollface"
  • Licensed under the MIT license.

Dependencies

~340KB