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
use clap::{Parser, Subcommand};
use std::path::PathBuf;
/// Time range filter for data queries
#[derive(Debug, Clone, Copy, Default, PartialEq)]
pub enum TimeRange {
Daily,
Weekly,
Monthly,
#[default]
All,
}
impl TimeRange {
/// Returns the cutoff date (inclusive) for filtering, or None for All
pub fn cutoff_date(&self) -> Option<chrono::NaiveDate> {
use chrono::{Datelike, Local};
let today = Local::now().date_naive();
match self {
TimeRange::All => None,
TimeRange::Daily => Some(today),
TimeRange::Weekly => {
let days_since_monday = today.weekday().num_days_from_monday() as i64;
Some(today - chrono::Duration::days(days_since_monday))
}
TimeRange::Monthly => Some(today.with_day(1).unwrap()),
}
}
}
/// Resolve time range from CLI flags (default: All)
pub fn resolve_time_range(daily: bool, weekly: bool, monthly: bool) -> TimeRange {
if daily {
TimeRange::Daily
} else if weekly {
TimeRange::Weekly
} else if monthly {
TimeRange::Monthly
} else {
TimeRange::All
}
}
/// Vibe Coding Tracker - AI coding assistant usage analyzer
#[derive(Parser, Debug)]
#[command(name = "vibe_coding_tracker")]
#[command(author, version = crate::VERSION, about, long_about = None)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
/// Analyze JSONL conversation files (single file or all sessions)
Analysis {
/// Path to the JSONL file to analyze (if not provided, analyzes all sessions)
#[arg(short, long, conflicts_with_all = ["json", "text", "table"])]
path: Option<PathBuf>,
/// Optional output path to save analysis result as JSON
#[arg(short, long)]
output: Option<PathBuf>,
/// Output raw JSON instead of table view
#[arg(long, group = "analysis_format")]
json: bool,
/// Output as plain text
#[arg(long, group = "analysis_format")]
text: bool,
/// Output as static table (instead of interactive TUI)
#[arg(long, group = "analysis_format")]
table: bool,
/// Show only today's data
#[arg(long, group = "period")]
daily: bool,
/// Show only this week's data
#[arg(long, group = "period")]
weekly: bool,
/// Show only this month's data
#[arg(long, group = "period")]
monthly: bool,
/// Show all data (default)
#[arg(long, group = "period")]
all: bool,
},
/// Display token usage statistics
Usage {
/// Output raw JSON instead of table view
#[arg(long, group = "usage_format")]
json: bool,
/// Output as plain text
#[arg(long, group = "usage_format")]
text: bool,
/// Output as static table
#[arg(long, group = "usage_format")]
table: bool,
/// Show only today's data
#[arg(long, group = "period")]
daily: bool,
/// Show only this week's data
#[arg(long, group = "period")]
weekly: bool,
/// Show only this month's data
#[arg(long, group = "period")]
monthly: bool,
/// Show all data (default)
#[arg(long, group = "period")]
all: bool,
},
/// Display version information
Version {
/// Output as JSON
#[arg(long)]
json: bool,
/// Output as plain text
#[arg(long)]
text: bool,
},
/// Update to the latest version from GitHub releases
Update {
/// Check for updates without installing
#[arg(long)]
check: bool,
/// Force update without confirmation prompt
#[arg(long, short)]
force: bool,
},
}