Add clap for more advanced argument parsing

This commit is contained in:
Strubbelkopp committed 2025-07-25 12:18:36 +02:00
1 parent 93e431196b
commit 473d5d0173
2 files changed
+14 -9

No files matched your search

+3 -1
View File
@@ -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"] }
+11 -8
View File
@@ -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;
#[derive(Parser)]
#[command(version, about, long_about = None)]
struct Args {
/// Text to display in the speech bubble
text: String,
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let args: Vec<String> = env::args().collect();
let args = Args::parse();
if args.len() == 1 {
println!("Usage: mikusays <text>");
println!("Example: mikusays \"Hello, World!\"");
return Ok(());
}
let text = args[1..].join(" ");
let text = args.text;
draw_miku_says(&text)?;
Ok(())