Skip to content

Commit 6e71eec

Browse files
committed
feat: add today and this-week shortcuts
Closes #1300
1 parent 10e3730 commit 6e71eec

15 files changed

Lines changed: 327 additions & 20 deletions

‎apps/ccusage/README.md‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ ccusage reads local usage data from coding agent CLIs and turns it into daily, w
6666
| GitHub Copilot CLI | `ccusage copilot daily` |
6767
| Gemini CLI | `ccusage gemini daily` |
6868

69-
Use `ccusage daily`, `ccusage weekly`, `ccusage monthly`, or `ccusage session` to include every detected source in one report.
69+
Use `ccusage today`, `ccusage this-week`, `ccusage daily`, `ccusage weekly`, `ccusage monthly`, or `ccusage session` to include every detected source in one report.
7070

7171
## Installation
7272

@@ -98,10 +98,12 @@ bunx -p https://pkg.pr.new/ccusage/ccusage@<pr-number> ccusage --offline
9898
# Basic usage
9999
bunx ccusage # Show all detected sources by day (default)
100100
bunx ccusage daily # All detected sources by day
101-
bunx ccusage weekly # All detected sources by week
102-
bunx ccusage monthly # All detected sources by month
103-
bunx ccusage session # All detected sources by session
104-
bunx ccusage blocks # Claude Code 5-hour billing windows
101+
bunx ccusage today # Today's usage across all detected sources
102+
bunx ccusage this-week # Daily usage since Monday
103+
bunx ccusage weekly # All detected sources by week
104+
bunx ccusage monthly # All detected sources by month
105+
bunx ccusage session # All detected sources by session
106+
bunx ccusage blocks # Claude Code 5-hour billing windows
105107
bunx ccusage statusline # Claude Code status line for hooks (Beta)
106108

107109
# Source-focused reports and options
@@ -126,6 +128,8 @@ bunx ccusage pi daily --pi-path /path/to/sessions,/archive/pi/sessions
126128
bunx ccusage daily --all
127129

128130
# Filters and options
131+
bunx ccusage today --json
132+
bunx ccusage this-week --timezone UTC
129133
bunx ccusage daily --since 2026-04-25 --until 2026-05-16
130134
bunx ccusage daily --json # JSON output
131135
bunx ccusage daily --no-cost # Hide cost columns and JSON cost fields

‎docs/guide/all-reports.md‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ ccusage aggregates every detected supported data source by default. You do not n
1010
# Daily usage across every detected source
1111
ccusage
1212
ccusage daily
13+
ccusage today
14+
ccusage this-week
1315

1416
# Other unified views
1517
ccusage weekly
1618
ccusage monthly
1719
ccusage session
1820
```
1921

22+
`ccusage today` shows the current day's daily rows. `ccusage this-week` shows daily rows from Monday through today. Both commands respect `--timezone`.
23+
2024
The `--all` flag is accepted for compatibility, but it is optional because unified views are already the default.
2125

2226
```bash
@@ -27,11 +31,13 @@ ccusage daily --all
2731

2832
ccusage detects local usage files from Claude Code, Codex, OpenCode, Amp, Droid, Codebuff, Hermes Agent, pi-agent, Goose, OpenClaw, Kilo, Kimi, Qwen, GitHub Copilot CLI, and Gemini CLI. The same daily, weekly, monthly, and session views can run in two modes:
2933

30-
| Mode | Command example | What it shows |
31-
| ------- | ---------------------- | --------------------------------------- |
32-
| Unified | `ccusage daily` | Every detected supported source |
33-
| Focused | `ccusage codex daily` | One source using the same report shape |
34-
| Focused | `ccusage claude daily` | One source with source-specific options |
34+
| Mode | Command example | What it shows |
35+
| ------- | ---------------------- | ---------------------------------------- |
36+
| Unified | `ccusage today` | Today's usage from every detected source |
37+
| Unified | `ccusage this-week` | Daily usage since Monday |
38+
| Unified | `ccusage daily` | Every detected supported source |
39+
| Focused | `ccusage codex daily` | One source using the same report shape |
40+
| Focused | `ccusage claude daily` | One source with source-specific options |
3541

3642
Unified tables include an **Agent** column so you can compare sources in one view. Focused views remove that comparison layer and show the selected source in more detail where applicable.
3743

‎docs/guide/cli-options.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ All ccusage commands support these global options:
1111
Filter usage data by date range:
1212

1313
```bash
14+
# Today's usage across all detected sources
15+
ccusage today
16+
17+
# Daily usage from Monday through today
18+
ccusage this-week
19+
1420
# Filter by date range
1521
ccusage daily --since 20260101 --until 20260531
1622

@@ -21,6 +27,8 @@ ccusage monthly --since 20260101
2127
ccusage session --until 20260531
2228
```
2329

30+
The `today` and `this-week` shortcuts respect `--timezone` when calculating their date range.
31+
2432
### Output Format
2533

2634
Control how data is displayed:

‎docs/guide/daily-reports.md‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Show all daily usage:
1010

1111
```bash
1212
ccusage daily
13+
ccusage today
14+
ccusage this-week
1315
# or simply:
1416
ccusage
1517

@@ -21,7 +23,7 @@ ccusage pi daily
2123
ccusage qwen daily
2224
```
2325

24-
The daily command is the default, so you can omit it when running ccusage.
26+
The daily command is the default, so you can omit it when running ccusage. Use `ccusage today` for the current day and `ccusage this-week` for daily rows from Monday through today.
2527

2628
## Example Output
2729

@@ -57,6 +59,12 @@ ccusage automatically adapts to your terminal width:
5759
Filter reports by date range:
5860

5961
```bash
62+
# Show today's usage
63+
ccusage today
64+
65+
# Show daily usage since Monday
66+
ccusage this-week
67+
6068
# Show usage from May 2026
6169
ccusage daily --since 20260501 --until 20260516
6270

@@ -67,6 +75,8 @@ ccusage daily --since 20260510 --until 20260516
6775
ccusage daily --since 20260501
6876
```
6977

78+
The shortcut commands respect `--timezone` when calculating today and the current week.
79+
7080
### Sort Order
7181

7282
Control the order of dates:

‎docs/guide/getting-started.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ Now that you have your first unified view, explore these features:
107107
### Monitor Daily Usage
108108

109109
```bash
110+
ccusage today
111+
ccusage this-week
110112
ccusage daily --since 2026-05-01 --until 2026-05-16
111113
```
112114

‎docs/guide/index.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ Some coding agents have been investigated but are not supported because their lo
100100
Run ccusage without a source name to aggregate all detected sources:
101101

102102
```bash
103+
ccusage today
104+
ccusage this-week
103105
ccusage daily
104106
ccusage weekly
105107
ccusage monthly

‎rust/crates/ccusage-cli/src/cli-commands.json‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
"name": "daily",
1616
"description": "Show all detected coding (agent) CLI usage grouped by date"
1717
},
18+
{
19+
"name": "today",
20+
"description": "Show all detected coding (agent) CLI usage for today"
21+
},
1822
{
1923
"name": "monthly",
2024
"description": "Show all detected coding (agent) CLI usage grouped by month"
@@ -23,6 +27,10 @@
2327
"name": "weekly",
2428
"description": "Show all detected coding (agent) CLI usage grouped by week"
2529
},
30+
{
31+
"name": "this-week",
32+
"description": "Show all detected coding (agent) CLI usage for this week grouped by date"
33+
},
2634
{
2735
"name": "session",
2836
"description": "Show all detected coding (agent) CLI usage grouped by session"
@@ -104,6 +112,12 @@
104112
"usage": "ccusage daily <OPTIONS>",
105113
"options": "all_agent_options"
106114
},
115+
{
116+
"path": ["today"],
117+
"description": "Show all detected coding (agent) CLI usage for today",
118+
"usage": "ccusage today <OPTIONS>",
119+
"options": "all_agent_options"
120+
},
107121
{
108122
"path": ["monthly"],
109123
"description": "Show all detected coding (agent) CLI usage grouped by month",
@@ -116,6 +130,12 @@
116130
"usage": "ccusage weekly <OPTIONS>",
117131
"options": "all_agent_options"
118132
},
133+
{
134+
"path": ["this-week"],
135+
"description": "Show all detected coding (agent) CLI usage for this week grouped by date",
136+
"usage": "ccusage this-week <OPTIONS>",
137+
"options": "all_agent_options"
138+
},
119139
{
120140
"path": ["session"],
121141
"description": "Show all detected coding (agent) CLI usage grouped by session",

‎rust/crates/ccusage-cli/src/lib.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ mod types;
55

66
pub use types::{
77
AgentCommandArgs, AgentReportKind, BlocksArgs, Cli, CliConfig, CodexSpeed, Command, CostMode,
8-
CostSource, DailyArgs, NoConfig, PricingOverride, SessionArgs, SharedArgs, SortOrder,
9-
StatuslineArgs, VisualBurnRate, WeekDay, WeeklyArgs, normalize_date_bound,
8+
CostSource, DailyArgs, NoConfig, PricingOverride, SessionArgs, SharedArgs, ShortcutCommand,
9+
SortOrder, StatuslineArgs, VisualBurnRate, WeekDay, WeeklyArgs, normalize_date_bound,
1010
};
1111

1212
#[cfg(test)]

‎rust/crates/ccusage-cli/src/parser.rs‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use crate::help::{print_help_and_exit, print_version_and_exit};
55
use crate::types::{OPENCODE_AGENT_REPORTS, STANDARD_AGENT_REPORTS};
66
use crate::{
77
AgentCommandArgs, AgentReportKind, BlocksArgs, Cli, CliConfig, CodexSpeed, Command, CostMode,
8-
CostSource, DailyArgs, NoConfig, SessionArgs, SharedArgs, SortOrder, StatuslineArgs,
9-
VisualBurnRate, WeekDay, WeeklyArgs, normalize_date_bound,
8+
CostSource, DailyArgs, NoConfig, SessionArgs, SharedArgs, ShortcutCommand, SortOrder,
9+
StatuslineArgs, VisualBurnRate, WeekDay, WeeklyArgs, normalize_date_bound,
1010
};
1111

1212
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
@@ -110,6 +110,8 @@ fn parse_command(
110110
) -> Result<Command, String> {
111111
match command {
112112
"daily" => parse_all_command(parser, shared, AgentReportKind::Daily, config),
113+
"today" => parse_shortcut_command(parser, shared, ShortcutCommand::Today),
114+
"this-week" => parse_shortcut_command(parser, shared, ShortcutCommand::ThisWeek),
113115
"monthly" => parse_all_command(parser, shared, AgentReportKind::Monthly, config),
114116
"weekly" => parse_all_command(parser, shared, AgentReportKind::Weekly, config),
115117
"session" => parse_top_level_session_command(parser, shared, config),
@@ -268,6 +270,21 @@ fn parse_command(
268270
}
269271
}
270272

273+
fn parse_shortcut_command(
274+
parser: &mut ArgParser,
275+
mut shared: SharedArgs,
276+
shortcut: ShortcutCommand,
277+
) -> Result<Command, String> {
278+
while parser.peek().is_some() {
279+
if matches!(parser.peek(), Some("--all")) {
280+
parser.next();
281+
continue;
282+
}
283+
parse_shared_arg(parser, &mut shared)?;
284+
}
285+
Ok(Command::Shortcut(shortcut, shared))
286+
}
287+
271288
fn parse_all_command(
272289
parser: &mut ArgParser,
273290
mut shared: SharedArgs,
@@ -611,6 +628,8 @@ fn is_command(arg: &str) -> bool {
611628
matches!(
612629
arg,
613630
"daily"
631+
| "today"
632+
| "this-week"
614633
| "monthly"
615634
| "weekly"
616635
| "session"

‎rust/crates/ccusage-cli/src/snapshots/ccusage_cli__tests__root_help.snap‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ USAGE:
88

99
COMMANDS:
1010
daily Show all detected coding (agent) CLI usage grouped by date
11+
today Show all detected coding (agent) CLI usage for today
1112
monthly Show all detected coding (agent) CLI usage grouped by month
1213
weekly Show all detected coding (agent) CLI usage grouped by week
14+
this-week Show all detected coding (agent) CLI usage for this week grouped by date
1315
session Show all detected coding (agent) CLI usage grouped by session
1416
blocks Show usage report grouped by session billing blocks
1517
statusline Display compact status line for Claude Code hooks with hybrid time+file caching (Beta)
@@ -31,8 +33,10 @@ COMMANDS:
3133

3234
For more info, run any command with the `--help` flag:
3335
ccusage daily --help
36+
ccusage today --help
3437
ccusage monthly --help
3538
ccusage weekly --help
39+
ccusage this-week --help
3640
ccusage session --help
3741
ccusage blocks --help
3842
ccusage statusline --help

0 commit comments

Comments
 (0)