Skip to content

Commit 883a10b

Browse files
committed
new cli commands
1 parent 9140045 commit 883a10b

5 files changed

Lines changed: 470 additions & 90 deletions

File tree

README.md

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,45 +22,67 @@ export PATH="$HOME/.local/bin:$PATH"
2222
Start using it:
2323

2424
```sh
25-
tody add "Buy groceries" # global task
26-
tody add "Fix login bug" --local # task scoped to this project
27-
tody # interactive picker
28-
tody list # print pending tasks
25+
tody add "Buy groceries" # global task (when not in a project)
26+
cd ~/projects/my-app
27+
tody add "Fix login bug" # auto-detected as local (you're in a git repo)
28+
tody add "Read docs" --global # explicitly global, even inside a project
29+
tody # interactive picker scoped to current project
30+
tody list # pending tasks for current project
31+
tody list --global # pending global tasks only
32+
tody list --all # everything across all projects
33+
tody list --done # completed tasks
2934
```
3035

31-
## Most-used commands
32-
33-
| Command | Description |
34-
|---------|-------------|
35-
| `tody` | Interactive picker to mark a task done |
36-
| `tody add <title>` | Add a task (`-l` / `--local` for project scope) |
37-
| `tody list` | List tasks (`-g`, `-l`, `-a`) |
38-
| `tody done <id>` | Mark task as completed |
39-
| `tody rm <id>` | Delete task (with confirmation) |
40-
| `tody log` | Show recently completed tasks |
41-
| `tody prune` | Remove tasks tied to deleted folders |
42-
| `tody update` | Self-update from GitHub releases |
36+
## Command quick guide
37+
38+
| If you want to... | Run | Result |
39+
|-------------------|-----|--------|
40+
| complete a task from a picker | `tody` | interactive prompt scoped to current project |
41+
| add a task (auto-scoped) | `tody add "Title"` | local when in a git repo, global otherwise |
42+
| add an explicitly global task | `tody add "Title" -g` | task is visible everywhere |
43+
| add an explicitly local task | `tody add "Title" -l` | task is tied to the current project |
44+
| see this project's tasks | `tody list` | local tasks for the current project only |
45+
| see global tasks | `tody list -g` | global tasks only |
46+
| see everything | `tody list -a` | all tasks across all projects |
47+
| see completed tasks here | `tody list -d` | completed tasks scoped to current context |
48+
| see all completed tasks | `tody list -a -d` | all completed tasks across projects |
49+
| mark a task completed by id | `tody done <id>` | marks one task as done |
50+
| edit a task's title | `tody edit <id> "New title"` | updates the task title |
51+
| undo the last completion | `tody undo` | restores the last completed task to pending |
52+
| permanently delete a task | `tody rm <id>` | removes one task after confirmation |
53+
54+
Other useful commands:
55+
56+
- `tody log`: recently completed activity (project-scoped by default)
57+
- `tody log --all`: completed activity across all projects
58+
- `tody prune`: remove tasks tied to deleted folders
59+
- `tody update`: self-update from GitHub releases
4360

4461
## What it does
4562

46-
- **Path-aware**: Local tasks are tied to your current project root.
63+
- **Project-scoped by default**: Inside a git repo, tasks are automatically local to that project.
64+
- **Smart auto-detection**: No flags needed — `tody add` and `tody list` just work in context.
4765
- **Zero config**: Works immediately with a local SQLite database.
4866
- **Single binary**: No runtime dependencies.
4967
- **Fast CLI flow**: Interactive picker plus explicit commands.
68+
- **Developer-friendly**: `edit`, `undo`, project-scoped `log`.
5069

5170
## Scope model
5271

5372
Every task is either:
5473

55-
- **Global**: visible from any folder.
56-
- **Local**: tied to a project path (nearest git root, or `cwd` fallback).
74+
- **Global**: visible from any folder. Created with `-g` flag, or auto-detected outside a git repo.
75+
- **Local**: tied to a project path (nearest git root). Auto-detected when inside a git repo.
76+
77+
When you `cd` into a project and run `tody`, you only see that project's tasks.
78+
Use `tody list -g` for global tasks, or `tody list -a` to see everything.
5779

5880
## Configuration
5981

6082
Config file (macOS/Linux): `~/.config/tody/config.toml`
6183

6284
```toml
63-
default_view = "merged" # merged | local | global
85+
default_view = "auto" # auto | merged | local | global
6486
color_local = "bright_magenta" # ANSI color name
6587
color_global = "bright_cyan" # ANSI color name
6688
```

demo.gif

159 KB
Loading

src/config.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ const CONFIG_FILENAME: &str = "config.toml";
1111
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
1212
#[serde(rename_all = "snake_case")]
1313
pub enum DefaultView {
14+
/// Auto-detect: project-local when in a git repo, global otherwise
1415
#[default]
16+
Auto,
1517
Merged,
1618
Local,
1719
Global,
@@ -20,6 +22,7 @@ pub enum DefaultView {
2022
impl Display for DefaultView {
2123
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
2224
match self {
25+
Self::Auto => write!(f, "auto"),
2326
Self::Merged => write!(f, "merged"),
2427
Self::Local => write!(f, "local"),
2528
Self::Global => write!(f, "global"),
@@ -32,10 +35,11 @@ impl FromStr for DefaultView {
3235

3336
fn from_str(value: &str) -> Result<Self, Self::Err> {
3437
match value.trim().to_ascii_lowercase().as_str() {
38+
"auto" => Ok(Self::Auto),
3539
"merged" => Ok(Self::Merged),
3640
"local" => Ok(Self::Local),
3741
"global" => Ok(Self::Global),
38-
_ => bail!("invalid default_view '{value}', expected merged|local|global"),
42+
_ => bail!("invalid default_view '{value}', expected auto|merged|local|global"),
3943
}
4044
}
4145
}
@@ -53,7 +57,7 @@ pub struct AppConfig {
5357
impl Default for AppConfig {
5458
fn default() -> Self {
5559
Self {
56-
default_view: DefaultView::Merged,
60+
default_view: DefaultView::Auto,
5761
color_local: default_color_local(),
5862
color_global: default_color_global(),
5963
}
@@ -134,6 +138,7 @@ mod tests {
134138

135139
#[test]
136140
fn parses_default_view_values() -> Result<()> {
141+
assert_eq!("auto".parse::<DefaultView>()?, DefaultView::Auto);
137142
assert_eq!("merged".parse::<DefaultView>()?, DefaultView::Merged);
138143
assert_eq!("local".parse::<DefaultView>()?, DefaultView::Local);
139144
assert_eq!("global".parse::<DefaultView>()?, DefaultView::Global);
@@ -168,7 +173,7 @@ mod tests {
168173
#[test]
169174
fn default_config_values() {
170175
let cfg = AppConfig::default();
171-
assert_eq!(cfg.default_view, DefaultView::Merged);
176+
assert_eq!(cfg.default_view, DefaultView::Auto);
172177
assert_eq!(cfg.color_local, "bright_magenta");
173178
assert_eq!(cfg.color_global, "bright_cyan");
174179
}

0 commit comments

Comments
 (0)