use clap::{Parser, Subcommand};
mod crops;
mod market;
mod models;
mod persistence;
mod plot_pricing;
mod stats;
mod buy_cmd;
mod buyplot_cmd;
mod harvest_cmd;
mod init_cmd;
mod inventory_cmd;
mod market_cmd;
mod plant_cmd;
mod sell_cmd;
mod stats_cmd;
mod view_cmd;
static VERSION: &str = env!("CARGO_PKG_VERSION");
#[derive(Parser)]
#[command(name = "termfarm")]
#[command(version = &VERSION)]
#[command(about = "A terminal idle farming game", long_about = None)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Init,
Stats,
Market,
Buy { seed_id: String, amount: u16 },
Plant { seed_id: String },
Harvest,
Inventory,
Sell {
crop_id: String,
amount: Option<u16>,
},
BuyPlot {
#[arg(long)]
showprice: bool,
},
View,
}
fn main() {
let cli = Cli::parse();
match &cli.command {
Commands::Init => {
init_cmd::init();
}
Commands::Stats => {
stats_cmd::stats();
}
Commands::Market => {
market_cmd::market();
}
Commands::Buy { seed_id, amount } => {
buy_cmd::buy(seed_id.to_string(), *amount);
}
Commands::Plant { seed_id } => {
plant_cmd::plant(seed_id.to_string());
}
Commands::Harvest => {
harvest_cmd::harvest();
}
Commands::Inventory => {
inventory_cmd::inventory();
}
Commands::Sell { crop_id, amount } => {
sell_cmd::sell(crop_id.to_string(), amount.unwrap_or(0));
}
Commands::BuyPlot { showprice } => {
buyplot_cmd::buyplot(*showprice);
}
Commands::View => {
view_cmd::view();
}
}
}