use anyhow::Result;
use clap::{Parser, Subcommand};
use std::io;
use crate::tarot::run_tarot_interpreter;
#[derive(Debug, Parser)]
struct MysticCli {
#[command(subcommand)]
command: Option<Command>,
}
#[derive(Debug, Subcommand)]
enum Command {
Tarot,
Astrology,
}
pub async fn run() -> Result<()> {
let result = match MysticCli::try_parse() {
Ok(value) => value,
Err(err) => {
println!("{}", err);
return Ok(());
}
};
let command = match result.command {
Some(value) => value,
None => return Ok(()),
};
match command {
Command::Tarot => run_tarot_interpreter().await?,
_ => todo!(),
}
Ok(())
}
pub fn run_loop() -> Result<()> {
let stdin = io::stdin(); loop {
let mut input = String::new();
stdin.read_line(&mut input)?;
let input = match MysticCli::try_parse_from(input.split_whitespace()) {
Ok(value) => value,
Err(err) => {
println!("whoops! {}", err);
continue;
}
};
println!("{:?} ", input);
}
}