todui/cli/
mod.rs

1use anyhow::Result;
2use clap::Parser;
3use crate::app::App;
4
5mod ls;
6mod add;
7mod delete;
8mod complete;
9mod config;
10mod cli_utils;
11
12// Shared enums and structs
13mod formats;
14
15#[derive(Parser)]
16#[command(author, version, about, long_about = None)]
17struct Args {
18    #[command(subcommand)]
19    command: Command,
20}
21
22#[derive(Parser)]
23enum Command {
24    /// Lists all the tasks
25    Ls(ls::Args),
26    /// Adds a task to your todos
27    Add(add::Args),
28    /// Deletes a task from your todos
29    Delete(delete::Args),
30    /// Marks a task as complete or incomplete
31    Complete(complete::Args),
32    /// Sets default configurations
33    Config(config::Args)
34}
35
36pub fn start_cli(app: App) -> Result<()> {
37    let args = Args::parse();
38
39    match args.command {
40        Command::Ls(args) => ls::run(app, args),
41        Command::Add(args) => add::run(app, args),
42        Command::Delete(args) => delete::run(app, args),
43        Command::Complete(args) => complete::run(app, args),
44        Command::Config(args) => config::run(app, args)
45    }
46}