tempo-cli 0.4.0

Automatic project time tracking CLI tool with beautiful terminal interface
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
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
use clap::{CommandFactory, Parser, Subcommand, ValueEnum};
use std::path::PathBuf;

#[derive(Parser)]
#[command(name = "tempo")]
#[command(about = "Automatic project time tracking CLI tool")]
#[command(version = env!("CARGO_PKG_VERSION"))]
#[command(author = "Tempo Contributors")]
pub struct Cli {
    #[command(subcommand)]
    pub command: Commands,

    #[arg(long, short, help = "Path to config file")]
    pub config: Option<PathBuf>,

    #[arg(long, short, help = "Verbose output")]
    pub verbose: bool,
}

#[derive(Subcommand)]
pub enum Commands {
    #[command(about = "Start the daemon")]
    Start,

    #[command(about = "Stop the daemon")]
    Stop,

    #[command(about = "Restart the daemon")]
    Restart,

    #[command(about = "Check daemon status")]
    Status,

    #[command(about = "Initialize a project for tracking")]
    Init {
        #[arg(help = "Project name")]
        name: Option<String>,

        #[arg(long, help = "Project path")]
        path: Option<PathBuf>,

        #[arg(long, help = "Project description")]
        description: Option<String>,
    },

    #[command(about = "List projects")]
    List {
        #[arg(long, help = "Include archived projects")]
        all: bool,

        #[arg(long, help = "Filter by tag")]
        tag: Option<String>,
    },

    #[command(about = "Generate time reports")]
    Report {
        #[arg(help = "Project name or ID")]
        project: Option<String>,

        #[arg(long, help = "Start date (YYYY-MM-DD)")]
        from: Option<String>,

        #[arg(long, help = "End date (YYYY-MM-DD)")]
        to: Option<String>,

        #[arg(long, help = "Export format (csv, json)")]
        format: Option<String>,

        #[arg(long, help = "Group by (day, week, month, project)")]
        group: Option<String>,
    },

    #[command(about = "Project management")]
    Project {
        #[command(subcommand)]
        action: ProjectAction,
    },

    #[command(about = "Session management")]
    Session {
        #[command(subcommand)]
        action: SessionAction,
    },

    #[command(about = "Tag management")]
    Tag {
        #[command(subcommand)]
        action: TagAction,
    },

    #[command(about = "Configuration management")]
    Config {
        #[command(subcommand)]
        action: ConfigAction,
    },

    #[command(about = "Interactive dashboard")]
    Dashboard,

    #[command(about = "Interactive project and session viewer")]
    Tui,

    #[command(about = "Interactive timer with visual progress")]
    Timer,

    #[command(about = "Browse session history")]
    History,

    #[command(about = "Goal management")]
    Goal {
        #[command(subcommand)]
        action: GoalAction,
    },

    #[command(about = "Productivity insights and analytics")]
    Insights {
        #[arg(long, help = "Period (daily, weekly, monthly)")]
        period: Option<String>,

        #[arg(long, help = "Project name or ID")]
        project: Option<String>,
    },

    #[command(about = "Weekly or monthly summary")]
    Summary {
        #[arg(help = "Period type (week, month)")]
        period: String,

        #[arg(long, help = "Start date (YYYY-MM-DD)")]
        from: Option<String>,
    },

    #[command(about = "Compare projects")]
    Compare {
        #[arg(help = "Project names or IDs (comma-separated)")]
        projects: String,

        #[arg(long, help = "Start date (YYYY-MM-DD)")]
        from: Option<String>,

        #[arg(long, help = "End date (YYYY-MM-DD)")]
        to: Option<String>,
    },

    #[command(about = "Show database pool statistics")]
    PoolStats,

    #[command(about = "Time estimation tracking")]
    Estimate {
        #[command(subcommand)]
        action: EstimateAction,
    },

    #[command(about = "Git branch tracking")]
    Branch {
        #[command(subcommand)]
        action: BranchAction,
    },

    #[command(about = "Project templates")]
    Template {
        #[command(subcommand)]
        action: TemplateAction,
    },

    #[command(about = "Workspace management")]
    Workspace {
        #[command(subcommand)]
        action: WorkspaceAction,
    },

    #[command(about = "Calendar integration")]
    Calendar {
        #[command(subcommand)]
        action: CalendarAction,
    },

    #[command(about = "Issue tracker integration")]
    Issue {
        #[command(subcommand)]
        action: IssueAction,
    },

    #[command(about = "Client reporting")]
    Client {
        #[command(subcommand)]
        action: ClientAction,
    },

    #[command(about = "Update tempo to the latest version")]
    Update {
        #[arg(long, help = "Check for updates without installing")]
        check: bool,

        #[arg(long, help = "Force update even if current version is latest")]
        force: bool,

        #[arg(long, help = "Show detailed update information")]
        verbose: bool,
    },

    #[command(about = "Generate shell completions", hide = true)]
    Completions {
        #[arg(help = "Shell to generate completions for")]
        shell: Shell,
    },

    #[command(about = "Display file contents")]
    Cat {
        #[arg(help = "Files to display")]
        files: Vec<PathBuf>,

        #[arg(short = 'A', long, help = "Equivalent to -vET")]
        show_all: bool,

        #[arg(short = 'b', long, help = "Number nonblank output lines, overrides -n")]
        number_nonblank: bool,

        #[arg(short = 'e', help = "Equivalent to -vE")]
        show_ends: bool,

        #[arg(short = 'E', long, help = "Display $ at end of each line")]
        show_ends_only: bool,

        #[arg(short = 'n', long, help = "Number all output lines")]
        number: bool,

        #[arg(short = 's', long, help = "Suppress repeated empty output lines")]
        squeeze_blank: bool,

        #[arg(short = 't', help = "Equivalent to -vT")]
        show_tabs: bool,

        #[arg(short = 'T', long, help = "Display TAB characters as ^I")]
        show_tabs_only: bool,

        #[arg(
            short = 'v',
            long,
            help = "Use ^ and M- notation, except for LFD and TAB"
        )]
        show_nonprinting: bool,

        #[arg(long, help = "Output version information and exit")]
        version: bool,
    },

    #[command(about = "Seed database with dummy data")]
    Seed,
}

#[derive(Subcommand)]
pub enum ProjectAction {
    #[command(about = "Archive a project")]
    Archive {
        #[arg(help = "Project name or ID")]
        project: String,
    },

    #[command(about = "Unarchive a project")]
    Unarchive {
        #[arg(help = "Project name or ID")]
        project: String,
    },

    #[command(about = "Update project path")]
    UpdatePath {
        #[arg(help = "Project name or ID")]
        project: String,

        #[arg(help = "New path")]
        path: PathBuf,
    },

    #[command(about = "Add tag to project")]
    AddTag {
        #[arg(help = "Project name or ID")]
        project: String,

        #[arg(help = "Tag name")]
        tag: String,
    },

    #[command(about = "Remove tag from project")]
    RemoveTag {
        #[arg(help = "Project name or ID")]
        project: String,

        #[arg(help = "Tag name")]
        tag: String,
    },
}

#[derive(Subcommand)]
pub enum SessionAction {
    #[command(about = "Start tracking time for current project")]
    Start {
        #[arg(long, help = "Project name or path")]
        project: Option<String>,

        #[arg(long, help = "Session context")]
        context: Option<String>,
    },

    #[command(about = "Stop current session")]
    Stop,

    #[command(about = "Pause current session")]
    Pause,

    #[command(about = "Resume paused session")]
    Resume,

    #[command(about = "Show current session")]
    Current,

    #[command(about = "List recent sessions")]
    List {
        #[arg(long, help = "Number of sessions to show")]
        limit: Option<usize>,

        #[arg(long, help = "Project filter")]
        project: Option<String>,
    },

    #[command(about = "Edit a session")]
    Edit {
        #[arg(help = "Session ID")]
        id: i64,

        #[arg(long, help = "New start time")]
        start: Option<String>,

        #[arg(long, help = "New end time")]
        end: Option<String>,

        #[arg(long, help = "New project")]
        project: Option<String>,

        #[arg(long, help = "Edit reason")]
        reason: Option<String>,
    },

    #[command(about = "Delete a session")]
    Delete {
        #[arg(help = "Session ID")]
        id: i64,

        #[arg(long, help = "Force deletion without confirmation")]
        force: bool,
    },

    #[command(about = "Merge multiple sessions into one")]
    Merge {
        #[arg(help = "Session IDs to merge (comma-separated)")]
        session_ids: String,

        #[arg(long, help = "Target project for merged session")]
        project: Option<String>,

        #[arg(long, help = "Notes for the merged session")]
        notes: Option<String>,
    },

    #[command(about = "Split a session into multiple sessions")]
    Split {
        #[arg(help = "Session ID to split")]
        session_id: i64,

        #[arg(help = "Split points (comma-separated times like '10:30,11:45')")]
        split_times: String,

        #[arg(long, help = "Notes for each split session (comma-separated)")]
        notes: Option<String>,
    },
}

#[derive(Subcommand)]
pub enum TagAction {
    #[command(about = "Create a new tag")]
    Create {
        #[arg(help = "Tag name")]
        name: String,

        #[arg(long, help = "Tag color")]
        color: Option<String>,

        #[arg(long, help = "Tag description")]
        description: Option<String>,
    },

    #[command(about = "List all tags")]
    List,

    #[command(about = "Delete a tag")]
    Delete {
        #[arg(help = "Tag name")]
        name: String,
    },
}

#[derive(Subcommand)]
pub enum ConfigAction {
    #[command(about = "Show current configuration")]
    Show,

    #[command(about = "Set configuration value")]
    Set {
        #[arg(help = "Configuration key")]
        key: String,

        #[arg(help = "Configuration value")]
        value: String,
    },

    #[command(about = "Get configuration value")]
    Get {
        #[arg(help = "Configuration key")]
        key: String,
    },

    #[command(about = "Reset configuration to defaults")]
    Reset,
}

#[derive(Subcommand)]
pub enum GoalAction {
    #[command(about = "Create a new goal")]
    Create {
        #[arg(help = "Goal name")]
        name: String,

        #[arg(help = "Target hours")]
        target_hours: f64,

        #[arg(long, help = "Project name or ID")]
        project: Option<String>,

        #[arg(long, help = "Goal description")]
        description: Option<String>,

        #[arg(long, help = "Start date (YYYY-MM-DD)")]
        start_date: Option<String>,

        #[arg(long, help = "End date (YYYY-MM-DD)")]
        end_date: Option<String>,
    },

    #[command(about = "List goals")]
    List {
        #[arg(long, help = "Project name or ID")]
        project: Option<String>,
    },

    #[command(about = "Update goal progress")]
    Update {
        #[arg(help = "Goal ID")]
        id: i64,

        #[arg(help = "Hours to add")]
        hours: f64,
    },
}

#[derive(Subcommand)]
pub enum EstimateAction {
    #[command(about = "Create a time estimate")]
    Create {
        #[arg(help = "Project name or ID")]
        project: String,

        #[arg(help = "Task name")]
        task: String,

        #[arg(help = "Estimated hours")]
        hours: f64,

        #[arg(long, help = "Due date (YYYY-MM-DD)")]
        due_date: Option<String>,
    },

    #[command(about = "Record actual time")]
    Record {
        #[arg(help = "Estimate ID")]
        id: i64,

        #[arg(help = "Actual hours")]
        hours: f64,
    },

    #[command(about = "List estimates")]
    List {
        #[arg(help = "Project name or ID")]
        project: String,
    },
}

#[derive(Subcommand)]
pub enum BranchAction {
    #[command(about = "List git branches for a project")]
    List {
        #[arg(help = "Project name or ID")]
        project: String,
    },

    #[command(about = "Show branch statistics")]
    Stats {
        #[arg(help = "Project name or ID")]
        project: String,

        #[arg(long, help = "Branch name")]
        branch: Option<String>,
    },
}

#[derive(Subcommand)]
pub enum TemplateAction {
    #[command(about = "Create a new project template")]
    Create {
        #[arg(help = "Template name")]
        name: String,

        #[arg(long, help = "Template description")]
        description: Option<String>,

        #[arg(long, help = "Default tags (comma-separated)")]
        tags: Option<String>,

        #[arg(long, help = "Workspace path for template")]
        workspace_path: Option<PathBuf>,
    },

    #[command(about = "List all templates")]
    List,

    #[command(about = "Delete a template")]
    Delete {
        #[arg(help = "Template name or ID")]
        template: String,
    },

    #[command(about = "Use a template to initialize a project")]
    Use {
        #[arg(help = "Template name or ID")]
        template: String,

        #[arg(help = "Project name")]
        project_name: String,

        #[arg(long, help = "Project path")]
        path: Option<PathBuf>,
    },
}

#[derive(Subcommand)]
pub enum WorkspaceAction {
    #[command(about = "Create a new workspace")]
    Create {
        #[arg(help = "Workspace name")]
        name: String,

        #[arg(long, help = "Workspace description")]
        description: Option<String>,

        #[arg(long, help = "Workspace path")]
        path: Option<PathBuf>,
    },

    #[command(about = "List all workspaces")]
    List,

    #[command(about = "Add project to workspace")]
    AddProject {
        #[arg(help = "Workspace name or ID")]
        workspace: String,

        #[arg(help = "Project name or ID")]
        project: String,
    },

    #[command(about = "Remove project from workspace")]
    RemoveProject {
        #[arg(help = "Workspace name or ID")]
        workspace: String,

        #[arg(help = "Project name or ID")]
        project: String,
    },

    #[command(about = "List projects in workspace")]
    Projects {
        #[arg(help = "Workspace name or ID")]
        workspace: String,
    },

    #[command(about = "Delete a workspace")]
    Delete {
        #[arg(help = "Workspace name or ID")]
        workspace: String,
    },
}

#[derive(Subcommand)]
pub enum CalendarAction {
    #[command(about = "Add a calendar event")]
    Add {
        #[arg(help = "Event name")]
        name: String,

        #[arg(help = "Start time (YYYY-MM-DD HH:MM)")]
        start: String,

        #[arg(long, help = "End time (YYYY-MM-DD HH:MM)")]
        end: Option<String>,

        #[arg(long, help = "Event type (meeting, focus_block, deadline)")]
        event_type: Option<String>,

        #[arg(long, help = "Project name or ID")]
        project: Option<String>,

        #[arg(long, help = "Event description")]
        description: Option<String>,
    },

    #[command(about = "List calendar events")]
    List {
        #[arg(long, help = "Start date (YYYY-MM-DD)")]
        from: Option<String>,

        #[arg(long, help = "End date (YYYY-MM-DD)")]
        to: Option<String>,

        #[arg(long, help = "Project name or ID")]
        project: Option<String>,
    },

    #[command(about = "Delete a calendar event")]
    Delete {
        #[arg(help = "Event ID")]
        id: i64,
    },
}

#[derive(Subcommand)]
pub enum IssueAction {
    #[command(about = "Sync issues from external tracker")]
    Sync {
        #[arg(help = "Project name or ID")]
        project: String,

        #[arg(long, help = "Issue tracker type (jira, github, gitlab)")]
        tracker_type: Option<String>,
    },

    #[command(about = "List issues for a project")]
    List {
        #[arg(help = "Project name or ID")]
        project: String,

        #[arg(long, help = "Filter by status")]
        status: Option<String>,
    },

    #[command(about = "Link session to issue")]
    Link {
        #[arg(help = "Session ID")]
        session_id: i64,

        #[arg(help = "Issue ID (external ID like JIRA-123)")]
        issue_id: String,
    },
}

#[derive(Subcommand)]
pub enum ClientAction {
    #[command(about = "Generate a client report")]
    Generate {
        #[arg(help = "Client name")]
        client: String,

        #[arg(help = "Start date (YYYY-MM-DD)")]
        from: String,

        #[arg(help = "End date (YYYY-MM-DD)")]
        to: String,

        #[arg(long, help = "Project filter (comma-separated)")]
        projects: Option<String>,

        #[arg(long, help = "Output format (json, csv, markdown)")]
        format: Option<String>,
    },

    #[command(about = "List all client reports")]
    List {
        #[arg(long, help = "Client name filter")]
        client: Option<String>,
    },

    #[command(about = "View a specific report")]
    View {
        #[arg(help = "Report ID")]
        id: i64,
    },
}

#[derive(ValueEnum, Clone, Debug)]
pub enum Shell {
    Bash,
    Zsh,
    Fish,
    PowerShell,
}

impl Cli {
    pub fn generate_completions(shell: Shell) {
        use clap_complete::{generate, shells};
        use std::io;

        let mut cmd = Self::command();
        match shell {
            Shell::Bash => generate(shells::Bash, &mut cmd, "tempo", &mut io::stdout()),
            Shell::Zsh => generate(shells::Zsh, &mut cmd, "tempo", &mut io::stdout()),
            Shell::Fish => generate(shells::Fish, &mut cmd, "tempo", &mut io::stdout()),
            Shell::PowerShell => generate(shells::PowerShell, &mut cmd, "tempo", &mut io::stdout()),
        }
    }
}