A light and fast library to create CLI apps.
Find a file
alyxshang ebe0c27d65
All checks were successful
/ test (push) Successful in 57s
Removed all references to crates.io.
2026-05-13 21:53:49 +02:00
.forgejo/workflows Nearly there. 2026-01-17 18:41:58 +01:00
src Bug fixed. 2026-01-18 20:44:23 +01:00
.gitignore Init. 2026-01-17 14:38:38 +01:00
Cargo.toml Prepped for crates.io. 2026-05-07 10:44:46 +02:00
LICENSE Init. 2026-01-17 14:38:38 +01:00
README.markdown Removed all references to crates.io. 2026-05-13 21:53:49 +02:00

YUE

Yue CI

A light and fast library to create CLI apps.

ABOUT

This repository contains the source code for a library to create CLI apps. Yuè (月) is the Chinese word for "moon" and like the moon, this library should illuminate the way for you clearly when building CLI applications in Rust. This library is a rewrite of an old library, called Cliply, which was far less flexible.

FEATURES

  • Built-in --help message.
  • Built-in --version message.
  • Support for the no-minus syntax: arg.
  • Support for the single minus syntax: -a.
  • Support for the combined minus syntax: -ab.
  • Support for the double-minus syntax: --arg.
  • Support for supplying data to an argument in each of the formats above.

INSTALLATION

To add the Yuè crate to your Rust project add the following line to the dependencies section of your project's Cargo.toml:

yue = { git = "https://source.alyxshang.boo/alyxshang/yue", tag = "v.0.1.0" }

USAGE

The code snippet below outlines how to create a CLI application using Yuè:

use yue::App;

fn main() {
    let mut app: App = App::new(
        "Test App",
        "0.1.0"
    );
    app.add_arg("greet", &false, "displays a greeting")
        .expect("Could not add argument.");
    app.add_arg("cgreet", &true, "displays a custom greeting")
        .expect("Could not add argument.");
    let mut stream: Vec<String> = std::env::args()
        .collect::<Vec<String>>();
    stream.remove(0);
    let _: () = app.parse_args(&stream)
        .expect("Could not parse arguments.");
    if app.arg_used("greet"){
        println!("Hello!");
    }
    else if app.arg_used("cgreet"){
        let data: String = app.get_arg_data("cgreet")
            .expect("Could not get argument data.");
        println!("Hello, {}!", data);
    }
    else {
        println!("{}", app.help_info().expect("Could not generate help message."));
    }
}

Please note that Yuè only accepts the collected vector of arguments supplied without the name of the exectuable being the first item in the vector of arguments. More information on the entities inside this crate can be obtained by cloning this repository and running the cargo doc --open command from the repository's root.

CHANGELOG

Version 0.1.0

  • Initial release.
  • Initial upload to Forgejo.

NOTE

  • Yuè by Alyx Shang.
  • Licensed under the FSL v1.