Crates.io | rspit |
lib.rs | rspit |
version | 0.3.2 |
source | src |
created_at | 2022-11-28 22:03:02.728275 |
updated_at | 2023-02-22 09:43:36.755261 |
description | A command-line tool to run Rust snippet. |
homepage | |
repository | https://github.com/NaokiM03/rspit |
max_upload_size | |
id | 724799 |
size | 1,687,510 |
Run Rust snippet containing multiple packages. Embed Cargo.toml
as a comment to avoid special formatting.
There is a simple cache system, as described below.
rust-analyzer supports single file
A large number of packages in one workspace makes rust-analyzer heavy. rust-analyzer's functionality is limited when opening single file, but it is very lightweight
$ cargo install rspit
# omitted
$ cat ./snippet.rs
//# [package]
//# name = "rand"
//# version = "0.1.0"
//# edition = "2021"
//#
//# [dependencies]
//# rand = "*"
use rand::prelude::*;
fn main() {
let num: u64 = random();
println!("num: {}", num);
}
//# ---
//# [package]
//# name = "json"
//# version = "0.1.0"
//# edition = "2021"
//#
//# [dependencies]
//# serde_json = "*"
use serde_json::{Result, Value};
fn main() -> Result<()> {
let json = r#"
{
"name": "Alice",
"age": 42
}
"#;
let json: Value = serde_json::from_str(json)?;
println!("name: {}, age: {}", json["name"], json["age"]);
Ok(())
}
$ pit run ./snippet.rs
# omitted cargo log messages
Run rand package
num: 17349477736480811228
# omitted cargo log messages
Run json package
name: "Alice", age: 42
$ pit --help
A command-line tool to run Rust snippet.
Usage: pit [COMMAND]
Commands:
check Check all package in file
build Build all package in file
run Run all package in file
release Build all package in file in release mode and copy the artifacts to the target directory
init Create a new file
list List all packages in the given file
add Add an empty package on top in the given file
extract Extract the package from file
clean Remove everything in the cache directory
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help information
-V, --version Print version information
target
directory is cachedrun
and build
are executedrun
execution and debug mode artifacts are present, the binary is executed directly without buildingPIT is released under the MIT License