aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorxxanqw <[email protected]>2025-09-22 19:12:22 +0300
committerxxanqw <[email protected]>2025-09-22 19:12:22 +0300
commit4455bb711d67e98ad1b46970c76e7572d6bbcaa1 (patch)
treece89523baef88a33c87cccde7203baefa8feb234 /src/main.rs
parent026117cc402803cb17dd87b9e69659a5ba96de9a (diff)
downloadmikusays-c-4455bb711d67e98ad1b46970c76e7572d6bbcaa1.tar.gz
mikusays-c-4455bb711d67e98ad1b46970c76e7572d6bbcaa1.zip
4 new styles; -l for listing all styles
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index e0ffba7..39fc9fe 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -9,26 +9,58 @@ use mikuart::get_miku_art;
#[command(version, about, long_about = None)]
struct Args {
/// Text to display in the speech bubble
- text: String,
+ text: Option<String>,
/// Style of the Miku art. A random one is chosen if not specified
#[arg(short, long)]
style: Option<i32>,
+
+ /// List all available art styles with their indices
+ #[arg(short, long)]
+ list: bool,
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = Args::parse();
- let text = args.text;
+ if args.list {
+ list_all_art_styles();
+ return Ok(());
+ }
+
+ let text = args.text.unwrap_or_else(|| {
+ eprintln!("Error: Text is required when not using --list");
+ std::process::exit(1);
+ });
let style = args.style.unwrap_or(-1); // Default to -1 to select a random style
draw_miku_says(&text, style)?;
Ok(())
}
+fn list_all_art_styles() {
+ println!("Available Miku art styles:");
+ println!("==========================");
+
+ // Get all art styles to determine the count
+ let all_art = get_miku_art(None, Some(true));
+ let styles_count = all_art.len();
+ println!("Total styles: {}", styles_count);
+
+ for i in 0..styles_count {
+ println!("\n--- Style {} ---", i);
+ let art = get_miku_art(Some(i as i32), Some(false));
+ for line in art {
+ println!("{}", line);
+ }
+ }
+
+ println!("\nUse --style <number> to select a specific style, or omit for random selection.");
+}
+
fn draw_miku_says(text: &str, style: i32) -> Result<(), Box<dyn std::error::Error>> {
let speech_bubble_lines = get_speech_bubble_lines(text);
- let miku_art = get_miku_art(style);
+ let miku_art = get_miku_art(Some(style), None);
let (window_width, window_height) = size()?;
let available_width = window_width as usize;