| Crates.io | mysh |
| lib.rs | mysh |
| version | 0.1.8 |
| created_at | 2024-01-25 02:20:09.134843+00 |
| updated_at | 2024-12-06 10:35:13.68824+00 |
| description | Scaffolding to build interactive shells |
| homepage | |
| repository | https://github.com/yuzuquats/mysh |
| max_upload_size | |
| id | 1113324 |
| size | 21,216 |
mysh, short for "My Shell", is a rust library for quickly building small interactive shells.
[dependencies]
mysh = "0.1.1"
futures = "0.3"
use mysh::{command, CommandArg};
use serde::Deserialize;
#[derive(CommandArg, Deserialize, Clone)]
pub struct Args {
name: String,
}
#[command(
name = "hello",
description = "Prints hello world",
long_description = "Prints hello world" // optional
)]
pub async fn hello(_: UserInfo, args: Args) -> mysh::Result<()> {
println!("Hello {}", args.name);
Ok(())
}
use mysh::Shell;
use tokio;
#[derive(Clone)]
pub struct UserInfo {}
// #[tokio::main] // or
#[actix_rt::main]
async fn main() {
Shell::new(UserInfo {})
.add_command(hello)
.run()
.await;
}
cargo run
>> hello --name World
Hello World
cargo run -- hello --name World
Hello World
cargo run -p simple