Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/grantshandy/claui
A GUI generator for clap-rs using egui
https://github.com/grantshandy/claui
Last synced: 4 days ago
JSON representation
A GUI generator for clap-rs using egui
- Host: GitHub
- URL: https://github.com/grantshandy/claui
- Owner: grantshandy
- License: gpl-3.0
- Created: 2022-03-10T20:56:29.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-20T09:14:39.000Z (about 2 months ago)
- Last Synced: 2024-10-29T06:56:05.202Z (14 days ago)
- Language: Rust
- Homepage:
- Size: 250 KB
- Stars: 100
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# claui
*Command Line Arguments (to graphical) User Interface*[![](https://img.shields.io/crates/v/claui.svg)](https://crates.io/crates/claui)
[![](https://img.shields.io/docsrs/claui)](https://docs.rs/claui)
[![](https://img.shields.io/crates/l/claui)](https://opensource.org/licenses/gpl-license)A GUI generator for [`clap`](https://github.com/clap-rs/clap) that uses [`egui`](https://github.com/emilk/egui).
![fizzbuzz screenshot](https://github.com/grantshandy/claui/blob/main/screenshots/fizzbuzz.png?raw=true)
## Builder Example
```rust
use clap::{arg, Command};fn main() {
let app = Command::new("Builder Greeter")
.author("Grant Handy ")
.version("1.2.3")
.about("A builder example for claui")
.arg(arg!(--name "Your name").default_value("Joe"))
.arg(arg!(--goodbye "Say goodbye"));claui::run(app, |matches| {
println!("Hello, {}!", matches.get_one::("name").unwrap());if matches.get_flag("goodbye") {
println!("Goodbye!");
}
});
}
```
![builder screenshot](https://github.com/grantshandy/claui/blob/main/screenshots/builder.png?raw=true)## Derive Example
```rust
use clap::{CommandFactory, Parser};#[derive(Parser, Debug)]
#[clap(
name = "Derive Greeter",
author = "Grant Handy ",
version = "1.2.3",
about = "A derive example for claui"
)]
struct Args {
#[clap(long, default_value = "Joe", help = "Your name")]
name: String,
#[clap(long, help = "Say goodbye")]
goodbye: bool,
}fn main() {
let app = Args::command();claui::run(app, |matches| {
println!("Hello, {}!", matches.get_one::("name").unwrap());if matches.get_flag("goodbye") {
println!("Goodbye!");
}
});
}
```
![derive example](https://github.com/grantshandy/claui/blob/main/screenshots/derive.png?raw=true)## Comparison with [`klask`](https://github.com/MichalGniadek/klask)
Klask is another GUI generator for [`clap`](https://github.com/clap-rs/clap) that uses [`egui`](https://github.com/emilk/egui), but claui and klask work in different ways. Klask runs your code by running itself as a child with an environment variable to ignore its GUI, then capturing the child's stdout. Claui only runs one process; it spawns your code in another thread and then reroutes all of your stdout into a buffer on each frame through [`shh`](https://github.com/kurtlawrence/shh).