use anyhow::Result;
use clap::{Parser, Subcommand};
mod commands;
mod models;
mod utils;
use commands::{init, list, move_task, new, open, save, search, show, update};
use models::{Config, Task};
#[derive(Parser)]
#[command(name = "tasks")]
#[command(about = "Fast task management for git repositories", long_about = None)]
#[command(version)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Init {
#[arg(short, long)]
project_name: Option<String>,
},
New {
#[arg(short, long)]
title: Option<String>,
#[arg(short, long)]
priority: Option<String>,
#[arg(short = 'g', long)]
tags: Option<String>,
#[arg(short, long)]
notes: Option<String>,
},
List {
status: Option<String>,
#[arg(short, long)]
priority: Option<String>,
#[arg(short, long)]
tag: Option<String>,
},
Show {
slug_or_id: String,
},
Update {
slug_or_id: String,
},
Move {
slug_or_id: String,
new_status: String,
},
Open {
slug_or_id: String,
},
Search {
query: String,
},
Save {
#[arg(short, long)]
message: Option<String>,
},
}
fn main() -> Result<()> {
let cli = Cli::parse();
match cli.command {
Commands::Init { project_name } => {
init(project_name)?;
}
Commands::New {
title,
priority,
tags,
notes,
} => {
new(title, priority, tags, notes)?;
}
Commands::List {
status,
priority,
tag,
} => {
list(status, priority, tag)?;
}
Commands::Show { slug_or_id } => {
show(slug_or_id)?;
}
Commands::Update { slug_or_id } => {
update(slug_or_id)?;
}
Commands::Move {
slug_or_id,
new_status,
} => {
move_task(slug_or_id, new_status)?;
}
Commands::Open { slug_or_id } => {
open(slug_or_id)?;
}
Commands::Search { query } => {
search(query)?;
}
Commands::Save { message } => {
save(message)?;
}
}
Ok(())
}