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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
use clap::{Parser, Subcommand, ValueEnum};
use crate::domain::Bucket;
#[derive(Debug, Parser)]
#[command(name = "tasu", version, about = "A terminal todo list that ages.")]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Command>,
}
/// A bucket name, for `list` and `move`.
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
pub enum BucketName {
Today,
Week,
Later,
}
impl From<BucketName> for Bucket {
fn from(value: BucketName) -> Self {
match value {
BucketName::Today => Bucket::Today,
BucketName::Week => Bucket::Week,
BucketName::Later => Bucket::Later,
}
}
}
/// Which list the history command shows.
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
pub enum HistoryName {
Done,
Dropped,
}
impl From<HistoryName> for crate::command::HistoryList {
fn from(value: HistoryName) -> Self {
match value {
HistoryName::Done => Self::Done,
HistoryName::Dropped => Self::Dropped,
}
}
}
#[derive(Debug, Subcommand)]
pub enum Command {
/// Add a task to today without opening the TUI.
#[command(visible_alias = "a")]
Add {
/// The task title.
#[arg(required = true, num_args = 1..)]
title: Vec<String>,
},
/// Print the open tasks, grouped by bucket.
#[command(visible_alias = "ls")]
List {
/// Only show this bucket.
#[arg(value_enum)]
bucket: Option<BucketName>,
/// Output a JSON array.
#[arg(long)]
json: bool,
},
/// Print completed and dropped tasks.
#[command(visible_alias = "h")]
History {
/// Which view to show; omit to show both.
#[arg(value_enum)]
view: Option<HistoryName>,
/// Output a JSON array.
#[arg(long)]
json: bool,
},
/// Complete an open task, matched by its exact title.
#[command(visible_alias = "d")]
Done {
/// The exact title of an open task.
#[arg(required = true, num_args = 1..)]
title: Vec<String>,
},
/// Drop (archive) an open task, matched by its exact title.
#[command(visible_alias = "x")]
Drop {
/// The exact title of an open task.
#[arg(required = true, num_args = 1..)]
title: Vec<String>,
},
/// Move an open task to a bucket, matched by its exact title.
#[command(visible_alias = "mv")]
Move {
/// The target bucket.
#[arg(value_enum)]
bucket: BucketName,
/// The exact title of an open task.
#[arg(required = true, num_args = 1..)]
title: Vec<String>,
},
/// Show the resolved data directory, config file and sync remote.
Config {
/// Output a JSON object.
#[arg(long)]
json: bool,
},
/// Show, set or clear the git sync remote.
Remote {
/// Remote URL, local path, or a GitHub `owner/repo` shorthand.
url: Option<String>,
/// Disable syncing.
#[arg(long)]
clear: bool,
},
/// Run one pull-then-push now and report the result.
Sync,
/// Update tasu, using however it was installed (Homebrew, the installer
/// script, or Cargo).
Update,
/// Print a shell completion script.
Completions {
/// The shell to generate for.
#[arg(value_enum)]
shell: clap_complete::Shell,
},
/// Internal: commit and push pending changes. Spawned detached by the TUI
/// on quit, so quitting never waits on the network.
#[command(hide = true)]
Flush,
}