diff options
| -rw-r--r-- | Cargo.toml | 4 | ||||
| -rw-r--r-- | src/main.rs | 19 |
2 files changed, 14 insertions, 9 deletions
@@ -1,9 +1,11 @@ [package] name = "mikusays" -version = "0.1.1" +version = "0.1.2" edition = "2024" +description = "A \"cowsay\" clone with Hatsune Miku ASCII art and speech bubbles." [dependencies] crossterm = "0.29" unicode-width = "0.2" rand = "0.9" +clap = { version = "4.5.41", features = ["derive"] } diff --git a/src/main.rs b/src/main.rs index e4d1b6e..d6313fa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,20 +1,23 @@ use crossterm::terminal::size; use std::env; use unicode_width::UnicodeWidthStr; +use clap::Parser; mod mikuart; use mikuart::get_miku_art; -fn main() -> Result<(), Box<dyn std::error::Error>> { - let args: Vec<String> = env::args().collect(); +#[derive(Parser)] +#[command(version, about, long_about = None)] +struct Args { + /// Text to display in the speech bubble + text: String, - if args.len() == 1 { - println!("Usage: mikusays <text>"); - println!("Example: mikusays \"Hello, World!\""); - return Ok(()); - } +} - let text = args[1..].join(" "); +fn main() -> Result<(), Box<dyn std::error::Error>> { + let args = Args::parse(); + + let text = args.text; draw_miku_says(&text)?; Ok(()) |
