5 unstable releases

0.4.0 Sep 20, 2024
0.2.0 Feb 13, 2023
0.1.2 Jul 25, 2022
0.1.1 May 20, 2022
0.1.0 May 20, 2022

#239 in GUI

Download history 160/week @ 2024-09-20 72/week @ 2024-09-27 11/week @ 2024-10-04 68/week @ 2024-10-11 6/week @ 2024-10-18 24/week @ 2024-11-01 6/week @ 2024-11-08 14/week @ 2024-11-15 7/week @ 2024-11-22

51 downloads per month
Used in visual-basm

GPL-3.0 license

110KB
316 lines

claui

Command Line Arguments (to graphical) User Interface

A GUI generator for clap that uses egui.

fizzbuzz screenshot

Builder Example

use clap::{arg, Command};

fn main() {
    let app = Command::new("Builder Greeter")
        .author("Grant Handy <grantshandy@gmail.com>")
        .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::<String>("name").unwrap());

        if matches.get_flag("goodbye") {
            println!("Goodbye!");
        }
    });
}

builder screenshot

Derive Example

use clap::{CommandFactory, Parser};

#[derive(Parser, Debug)]
#[clap(
    name = "Derive Greeter",
    author = "Grant Handy <grantshandy@gmail.com>",
    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::<String>("name").unwrap());

        if matches.get_flag("goodbye") {
            println!("Goodbye!");
        }
    });
}

derive example

Comparison with klask

Klask is another GUI generator for clap that uses 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.

Dependencies

~8–25MB
~417K SLoC