- Rust 100%
|
|
||
|---|---|---|
| .forgejo/workflows | ||
| src | ||
| .gitignore | ||
| Cargo.toml | ||
| LICENSE | ||
| README.markdown | ||
YUE
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
--helpmessage. - Built-in
--versionmessage. - 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.