1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
use clap::{Args, Parser, Subcommand};
use crate::config::Language;
/// A To-Do CLI application for managing your daily tasks
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
}
/// Subcommands for the application
#[derive(Subcommand, Debug)]
pub enum Command {
/// Creates a new task
Create(CreateTask),
/// Edits an existing task
Edit(EditTask),
/// Marks a task as complete
Complete(CompleteTask),
/// Deletes a task, whether completed or not
Delete(DeleteTask),
/// Cleans all completed tasks
Clean,
/// Lists all tasks
List,
/// Configures the application
Config(ConfigApp),
/// Get path to the configuration file
Path,
}
#[derive(Args, Debug)]
pub struct CreateTask {
/// Name of the task
pub task: String,
}
#[derive(Args, Debug)]
pub struct EditTask {
/// ID of the task to edit
pub id: usize,
/// New body for the task
pub task: String,
}
#[derive(Args, Debug)]
pub struct CompleteTask {
/// ID of the task to toggle
pub id: usize,
}
#[derive(Args, Debug)]
pub struct DeleteTask {
/// ID of the task to delete
pub id: usize,
}
#[derive(Args, Debug)]
pub struct ConfigApp {
/// Name of the user
#[arg(short, long)]
pub name: String,
/// Language for the program to use
#[arg(value_enum, short, long)]
pub language: Language,
}