rustodo 2.26.0

A modern, powerful task manager built with Rust
Documentation
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
//! Command-line interface definitions.

use clap::{Args, Parser, Subcommand};

use crate::models::{
    Difficulty, DueFilter, Priority, Recurrence, RecurrenceFilter, ResourceType, SortBy,
    StatusFilter,
};

#[derive(Parser)]
#[command(name = "rustodo")]
#[command(author = "github.com/joaofelipegalvao")]
#[command(version)]
#[command(about = "A modern, powerful task manager built with Rust", long_about = None)]
#[command(override_usage = "todo [COMMAND]")]
#[command(after_help = "\
COMMANDS:
  Task Management:
    add (a), list (ls), done, undone, edit (e), remove (rm), clear, recur, clear-recur

  Viewing & Planning:
    next (n), calendar (cal), stats, search (find), context (ctx), deps, tags

  Organization:
    project, note, resource

  System:
    info, purge, holidays, backup, restore, backup-list, export, import

Run 'todo <COMMAND> --help' for more information on a command.
")]
pub struct Cli {
    #[command(subcommand)]
    pub command: Option<Commands>,
}

#[derive(Subcommand)]
pub enum Commands {
    // ── Task Management ───────────────────────────────────────────────────────
    /// Add a new task to your todo list
    #[command(visible_alias = "a", hide = true)]
    Add(AddArgs),

    /// List and filter tasks
    #[command(visible_alias = "ls", hide = true)]
    List {
        #[arg(long, value_enum, default_value_t = StatusFilter::All)]
        status: StatusFilter,
        #[arg(long, value_enum)]
        priority: Option<Priority>,
        #[arg(long, value_enum)]
        due: Option<DueFilter>,
        #[arg(long, short = 's', value_enum)]
        sort: Option<SortBy>,
        #[arg(long, short = 't', value_delimiter = ',')]
        tag: Vec<String>,
        #[arg(long, short = 'p')]
        project: Option<String>,
        #[arg(long, short = 'r', value_enum)]
        recurrence: Option<RecurrenceFilter>,
    },

    /// Mark a task as completed
    #[command(visible_alias = "complete", hide = true)]
    Done {
        #[arg(value_name = "ID")]
        id: usize,
    },

    /// Mark a completed task as pending
    #[command(visible_alias = "undo", hide = true)]
    Undone {
        #[arg(value_name = "ID")]
        id: usize,
    },

    /// Edit an existing task
    #[command(visible_alias = "e", hide = true)]
    Edit(EditArgs),

    /// Remove a task permanently
    #[command(visible_aliases = ["rm", "delete"], hide = true)]
    Remove {
        #[arg(value_name = "ID")]
        id: usize,
        #[arg(long, short = 'y')]
        yes: bool,
    },

    /// Clear all tasks
    #[command(visible_alias = "reset", hide = true)]
    Clear {
        #[arg(long, short = 'y')]
        yes: bool,
    },

    /// Set or change recurrence pattern for a task
    #[command(hide = true)]
    Recur {
        #[arg(value_name = "ID")]
        id: usize,
        #[arg(value_enum)]
        pattern: Recurrence,
    },

    /// Remove recurrence pattern from a task
    #[command(visible_alias = "norecur", hide = true)]
    ClearRecur {
        #[arg(value_name = "ID")]
        id: usize,
    },

    // ── Viewing & Planning ────────────────────────────────────────────────────
    /// Show the most urgent pending tasks ready to work on
    #[command(visible_alias = "n", hide = true)]
    Next {
        /// How many tasks to show (default: 5).
        #[arg(long, short = 'n', default_value_t = 5)]
        limit: usize,
    },

    /// Show a monthly calendar with due dates for tasks and projects
    #[command(visible_alias = "cal", hide = true)]
    Calendar {
        /// Month (1-12). Defaults to current month.
        #[arg(value_name = "MONTH")]
        month: Option<u32>,
        /// Year (e.g. 2026). Defaults to current year.
        #[arg(value_name = "YEAR")]
        year: Option<i32>,
    },

    /// Show productivity statistics and activity chart
    #[command(hide = true)]
    Stats,

    /// Search for tasks by text content
    #[command(visible_alias = "find", hide = true)]
    Search {
        #[arg(value_name = "QUERY")]
        query: String,
        #[arg(long, short = 't', value_delimiter = ',')]
        tag: Vec<String>,
        #[arg(long, short = 'p')]
        project: Option<String>,
        #[arg(long, value_enum, default_value_t = StatusFilter::All)]
        status: StatusFilter,
    },

    /// Show everything linked to a task: project, dependencies, notes, resources
    #[command(visible_alias = "ctx", hide = true)]
    Context {
        #[arg(value_name = "ID")]
        id: usize,
    },

    /// Show dependency graph for a task
    #[command(hide = true)]
    Deps {
        #[arg(value_name = "ID")]
        id: usize,
    },

    /// List all tags with counts, or show hub view for a specific tag
    #[command(hide = true)]
    Tags {
        /// Optional tag name to show hub view (all tasks, notes, resources with this tag).
        #[arg(value_name = "TAG")]
        tag: Option<String>,
    },

    // ── Organization ─────────────────────────────────────────────────────────
    /// Manage projects
    #[command(subcommand, hide = true)]
    Project(ProjectCommands),

    /// Manage notes (documentation linked to projects, tasks, or resources)
    #[command(subcommand, hide = true)]
    Note(NoteCommands),

    /// Manage resources (external references: links, docs, assets)
    #[command(subcommand, hide = true)]
    Resource(ResourceCommands),

    // ── System ────────────────────────────────────────────────────────────────
    /// Export all data to a JSON file
    #[command(hide = true)]
    Export {
        /// Output file path. Defaults to rustodo-export-YYYY-MM-DD.json
        #[arg(value_name = "FILE")]
        file: Option<std::path::PathBuf>,
    },

    /// Import data from a JSON export file
    #[command(hide = true)]
    Import {
        /// Path to the JSON export file
        #[arg(value_name = "FILE")]
        file: std::path::PathBuf,
        /// Replace all existing data instead of merging
        #[arg(long)]
        replace: bool,
        #[arg(long, short = 'y')]
        yes: bool,
    },

    /// Create a manual database backup
    #[command(hide = true)]
    Backup,

    /// Restore database from a backup file
    #[command(hide = true)]
    Restore {
        /// Path to the backup file. If omitted, lists available backups to choose from.
        #[arg(value_name = "FILE")]
        file: Option<std::path::PathBuf>,
        #[arg(long, short = 'y')]
        yes: bool,
    },

    /// List available backups
    #[command(name = "backup-list", hide = true)]
    BackupList,

    /// Show information about data file location
    #[command(hide = true)]
    Info,

    /// Permanently remove soft-deleted tombstones
    #[command(hide = true)]
    Purge {
        #[arg(long, default_value_t = 30)]
        days: u32,
        #[arg(long)]
        dry_run: bool,
        #[arg(long, short = 'y')]
        yes: bool,
    },

    /// Manage holiday data from holidata.net
    #[command(subcommand, hide = true)]
    Holidays(HolidaysCommands),
}

// ── Project subcommands ───────────────────────────────────────────────────────

#[derive(Subcommand)]
pub enum ProjectCommands {
    /// Add a new project.
    Add(ProjectAddArgs),
    /// List all projects.
    List,
    /// Show full details of a project.
    Show {
        #[arg(value_name = "ID")]
        id: usize,
    },
    /// Edit an existing project.
    Edit(ProjectEditArgs),
    /// Mark a project as completed.
    Done {
        #[arg(value_name = "ID")]
        id: usize,
    },
    /// Mark a completed project as pending.
    Undone {
        #[arg(value_name = "ID")]
        id: usize,
    },
    /// Remove a project (soft delete).
    Remove {
        #[arg(value_name = "ID")]
        id: usize,
        #[arg(long, short = 'y')]
        yes: bool,
    },
    /// Clear all projects (soft delete).
    Clear {
        #[arg(long, short = 'y')]
        yes: bool,
    },
}

// ── ProjectAddArgs ────────────────────────────────────────────────────────────

#[derive(Args)]
pub struct ProjectAddArgs {
    #[arg(value_name = "NAME")]
    pub name: String,
    #[arg(long, value_enum)]
    pub difficulty: Option<Difficulty>,
    #[arg(long, value_delimiter = ',')]
    pub tech: Vec<String>,
    #[arg(long, value_name = "DATE|EXPRESSION")]
    pub due: Option<String>,
}

// ── ProjectEditArgs ───────────────────────────────────────────────────────────

#[derive(Args)]
pub struct ProjectEditArgs {
    #[arg(value_name = "ID")]
    pub id: usize,
    #[arg(long)]
    pub name: Option<String>,
    #[arg(long, value_enum)]
    pub difficulty: Option<Difficulty>,
    /// Mark project as completed.
    #[arg(long, conflicts_with = "undone")]
    pub done: bool,
    /// Mark project as pending.
    #[arg(long, conflicts_with = "done")]
    pub undone: bool,
    #[arg(long, value_delimiter = ',', conflicts_with = "clear_tech")]
    pub add_tech: Vec<String>,
    #[arg(long, value_delimiter = ',', conflicts_with = "clear_tech")]
    pub remove_tech: Vec<String>,
    #[arg(long, conflicts_with_all = ["add_tech", "remove_tech"])]
    pub clear_tech: bool,
    #[arg(long, value_name = "DATE|EXPRESSION", conflicts_with = "clear_due")]
    pub due: Option<String>,
    #[arg(long, conflicts_with = "due")]
    pub clear_due: bool,
}

// ── Note subcommands ──────────────────────────────────────────────────────────

#[derive(Subcommand)]
pub enum NoteCommands {
    /// Add a new note.
    Add(NoteAddArgs),
    /// List notes with optional filters.
    List(NoteListArgs),
    /// Show the full content of a note.
    Show {
        #[arg(value_name = "ID")]
        id: usize,
    },
    /// Preview note body with markdown rendering (requires bat).
    Preview {
        #[arg(value_name = "ID")]
        id: usize,
    },
    /// Edit an existing note.
    Edit(NoteEditArgs),
    /// Remove a note (soft delete).
    Remove {
        #[arg(value_name = "ID")]
        id: usize,
        #[arg(long, short = 'y')]
        yes: bool,
    },
    /// Clear all notes (soft delete).
    Clear {
        #[arg(long, short = 'y')]
        yes: bool,
    },
}

// ── NoteAddArgs ───────────────────────────────────────────────────────────────

#[derive(Args)]
pub struct NoteAddArgs {
    /// Note body (short text). Mutually exclusive with --editor and --file.
    #[arg(value_name = "BODY", conflicts_with_all = ["editor", "file"])]
    pub body: Option<String>,
    /// Open $EDITOR to write the note body. Mutually exclusive with <BODY> and --file.
    #[arg(long, conflicts_with_all = ["file"])]
    pub editor: bool,
    /// Read note body from a markdown file. Mutually exclusive with <BODY> and --editor.
    #[arg(long, value_name = "PATH", conflicts_with_all = ["editor"])]
    pub file: Option<std::path::PathBuf>,
    #[arg(long)]
    pub title: Option<String>,
    #[arg(long, short = 't', value_delimiter = ',')]
    pub tag: Vec<String>,
    #[arg(long, short = 'l')]
    pub language: Option<String>,
    #[arg(long, short = 'p')]
    pub project: Option<String>,
    #[arg(long)]
    pub task: Option<usize>,
}

// ── NoteListArgs ──────────────────────────────────────────────────────────────

#[derive(Args)]
pub struct NoteListArgs {
    #[arg(long, short = 'p')]
    pub project: Option<String>,
    #[arg(long, short = 't')]
    pub tag: Option<String>,
    #[arg(long, short = 'l')]
    pub language: Option<String>,
}

// ── NoteEditArgs ──────────────────────────────────────────────────────────────

#[derive(Args)]
pub struct NoteEditArgs {
    #[arg(value_name = "ID")]
    pub id: usize,
    /// Edit body inline. Mutually exclusive with --editor.
    #[arg(long, conflicts_with = "editor")]
    pub body: Option<String>,
    /// Open $EDITOR to edit the note body. Mutually exclusive with --body.
    #[arg(long, conflicts_with = "body")]
    pub editor: bool,
    #[arg(long, conflicts_with = "clear_title")]
    pub title: Option<String>,
    #[arg(long, conflicts_with = "title")]
    pub clear_title: bool,
    #[arg(long, short = 'l', conflicts_with = "clear_language")]
    pub language: Option<String>,
    #[arg(long, conflicts_with = "language")]
    pub clear_language: bool,
    #[arg(long, value_delimiter = ',', conflicts_with = "clear_tags")]
    pub add_tag: Vec<String>,
    #[arg(long, value_delimiter = ',', conflicts_with = "clear_tags")]
    pub remove_tag: Vec<String>,
    #[arg(long, conflicts_with_all = ["add_tag", "remove_tag"])]
    pub clear_tags: bool,
    #[arg(long, short = 'p', conflicts_with = "clear_project")]
    pub project: Option<String>,
    #[arg(long, conflicts_with = "project")]
    pub clear_project: bool,
    #[arg(long, conflicts_with = "clear_task")]
    pub task: Option<usize>,
    #[arg(long, conflicts_with = "task")]
    pub clear_task: bool,
    /// Link one or more resources to this note by display ID.
    #[arg(long, value_name = "ID", conflicts_with = "clear_resources")]
    pub add_resource: Vec<usize>,
    /// Unlink one or more resources from this note by display ID.
    #[arg(long, value_name = "ID", conflicts_with = "clear_resources")]
    pub remove_resource: Vec<usize>,
    /// Remove all resource links from this note.
    #[arg(long, conflicts_with_all = ["add_resource", "remove_resource"])]
    pub clear_resources: bool,
}

// ── Resource subcommands ──────────────────────────────────────────────────────

#[derive(Subcommand)]
pub enum ResourceCommands {
    /// Add a new resource.
    Add(ResourceAddArgs),
    /// List all resources.
    List(ResourceListArgs),
    /// Show full details of a resource.
    Show {
        #[arg(value_name = "ID")]
        id: usize,
    },
    /// Edit an existing resource.
    Edit(ResourceEditArgs),
    /// Remove a resource (soft delete).
    Remove {
        #[arg(value_name = "ID")]
        id: usize,
        #[arg(long, short = 'y')]
        yes: bool,
    },
    /// Clear all resources (soft delete).
    Clear {
        #[arg(long, short = 'y')]
        yes: bool,
    },
}

// ── ResourceAddArgs ───────────────────────────────────────────────────────────

#[derive(Args)]
pub struct ResourceAddArgs {
    #[arg(value_name = "TITLE")]
    pub title: String,
    #[arg(long, value_enum)]
    pub r#type: Option<ResourceType>,
    #[arg(long, short = 'u')]
    pub url: Option<String>,
    #[arg(long, short = 'd')]
    pub description: Option<String>,
    #[arg(long, short = 't', value_delimiter = ',')]
    pub tag: Vec<String>,
}

// ── ResourceListArgs ──────────────────────────────────────────────────────────

#[derive(Args)]
pub struct ResourceListArgs {
    #[arg(long, short = 't')]
    pub tag: Option<String>,
    #[arg(long, value_enum)]
    pub r#type: Option<ResourceType>,
}

// ── ResourceEditArgs ──────────────────────────────────────────────────────────

#[derive(Args)]
pub struct ResourceEditArgs {
    #[arg(value_name = "ID")]
    pub id: usize,
    #[arg(long)]
    pub title: Option<String>,
    #[arg(long, value_enum, conflicts_with = "clear_type")]
    pub r#type: Option<ResourceType>,
    #[arg(long, conflicts_with = "type")]
    pub clear_type: bool,
    #[arg(long, short = 'u', conflicts_with = "clear_url")]
    pub url: Option<String>,
    #[arg(long, conflicts_with = "url")]
    pub clear_url: bool,
    #[arg(long, short = 'd', conflicts_with = "clear_description")]
    pub description: Option<String>,
    #[arg(long, conflicts_with = "description")]
    pub clear_description: bool,
    #[arg(long, value_delimiter = ',', conflicts_with = "clear_tags")]
    pub add_tag: Vec<String>,
    #[arg(long, value_delimiter = ',', conflicts_with = "clear_tags")]
    pub remove_tag: Vec<String>,
    #[arg(long, conflicts_with_all = ["add_tag", "remove_tag"])]
    pub clear_tags: bool,
}

// ── Sync subcommands ──────────────────────────────────────────────────────────

#[derive(Subcommand)]
pub enum SyncCommands {
    Init {
        #[arg(value_name = "REMOTE")]
        remote: String,
    },
    Push,
    Pull,
    Status,
}

// ── AddArgs ───────────────────────────────────────────────────────────────────

#[derive(Args)]
pub struct AddArgs {
    #[arg(value_name = "DESCRIPTION")]
    pub text: String,
    #[arg(long, value_enum, default_value_t = Priority::Medium)]
    pub priority: Priority,
    #[arg(long, short = 't', value_name = "TAG", value_delimiter = ',')]
    pub tag: Vec<String>,
    #[arg(long, short = 'p', value_name = "PROJECT")]
    pub project: Option<String>,
    #[arg(long, value_name = "DATE|EXPRESSION")]
    pub due: Option<String>,
    #[arg(long, value_enum)]
    pub recurrence: Option<Recurrence>,
    #[arg(long, value_name = "ID")]
    pub depends_on: Vec<usize>,
}

// ── EditArgs ──────────────────────────────────────────────────────────────────

#[derive(Args)]
pub struct EditArgs {
    #[arg(value_name = "ID")]
    pub id: usize,
    #[arg(long)]
    pub text: Option<String>,
    #[arg(long, value_enum)]
    pub priority: Option<Priority>,
    #[arg(long, value_delimiter = ',')]
    pub add_tag: Vec<String>,
    #[arg(long, value_delimiter = ',')]
    pub remove_tag: Vec<String>,
    #[arg(long, short = 'p', conflicts_with = "clear_project")]
    pub project: Option<String>,
    #[arg(long, conflicts_with = "project")]
    pub clear_project: bool,
    #[arg(long, value_name = "DATE|EXPRESSION")]
    pub due: Option<String>,
    #[arg(long, conflicts_with = "due")]
    pub clear_due: bool,
    #[arg(long, conflicts_with_all = ["add_tag", "remove_tag"])]
    pub clear_tags: bool,
    #[arg(long, value_name = "ID", conflicts_with = "clear_deps")]
    pub add_dep: Vec<usize>,
    #[arg(long, value_name = "ID", conflicts_with = "clear_deps")]
    pub remove_dep: Vec<usize>,
    #[arg(long, conflicts_with_all = ["add_dep", "remove_dep"])]
    pub clear_deps: bool,
}

// ── Holidays subcommands ──────────────────────────────────────────────────────

#[derive(Subcommand)]
pub enum HolidaysCommands {
    /// Download or refresh holiday data from holidata.net for the configured locale.
    Refresh,
}