khaki

Crates.iokhaki
lib.rskhaki
version0.2.0
sourcesrc
created_at2020-08-06 02:00:48.569089
updated_at2021-04-21 04:11:59.77496
descriptionA tool to write rust scripts with less boilerplate
homepagehttps://github.com/staktrace/khaki/blob/master/README.md
repositoryhttps://github.com/staktrace/khaki
max_upload_size
id273491
size15,410
Kartikaya Gupta (kats) (staktrace)

documentation

README

khaki

A tool that lets you write quick-and-dirty rust "scripts" with less boilerplate.

Example usage

$ cargo install khaki
$ cat examples/echo.rs | examples/echo.rs
#!/usr/bin/env khaki

let stdin = stdin();
loop {
    let mut buf = String::new();
    match stdin.read_line(&mut buf) {
        Ok(0) => break,
        Ok(_) => print!("{}", buf),
        _ => exit(1),
    };
}

In case it's not obvious from the above example, the examples/echo.rs file is standard Rust code, but without the boilerplate of a main function and use statements. And it's an executable (chmod +x) file with a shebang line that runs it via the khaki "interpreter". The "interpreter" really just preprocesses the script to insert the missing boilerplate, and then compiles it with rustc and executes it.

Goals

The overarching goal of khaki is to make it as easy to use Rust in one-off scripts as it is to use Python.

FAQ

Q: Why the name "khaki"? A: It's a color that's lighter than rust.

Commit count: 22

cargo fmt