Skip to content

Commit 64c0b03

Browse files
authored
Merge pull request #11 from FlorianBruniaux/feat/quota-analysis
feat: add quota analysis with multi-tier support
2 parents 341c485 + 26b314d commit 64c0b03

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

src/gain.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use anyhow::Result;
22
use crate::tracking::Tracker;
33

4-
pub fn run(graph: bool, history: bool, verbose: u8) -> Result<()> {
4+
pub fn run(graph: bool, history: bool, quota: bool, tier: &str, _verbose: u8) -> Result<()> {
55
let tracker = Tracker::new()?;
66
let summary = tracker.get_summary()?;
77

@@ -68,6 +68,29 @@ pub fn run(graph: bool, history: bool, verbose: u8) -> Result<()> {
6868
}
6969
}
7070

71+
if quota {
72+
const ESTIMATED_PRO_MONTHLY: usize = 6_000_000; // ~6M tokens/month (heuristic: ~44K/5h × 6 periods/day × 30 days)
73+
74+
let (quota_tokens, tier_name) = match tier {
75+
"pro" => (ESTIMATED_PRO_MONTHLY, "Pro ($20/mo)"),
76+
"5x" => (ESTIMATED_PRO_MONTHLY * 5, "Max 5x ($100/mo)"),
77+
"20x" => (ESTIMATED_PRO_MONTHLY * 20, "Max 20x ($200/mo)"),
78+
_ => (ESTIMATED_PRO_MONTHLY, "Pro ($20/mo)"), // default fallback
79+
};
80+
81+
let quota_pct = (summary.total_saved as f64 / quota_tokens as f64) * 100.0;
82+
83+
println!("Monthly Quota Analysis:");
84+
println!("────────────────────────────────────────");
85+
println!("Subscription tier: {}", tier_name);
86+
println!("Estimated monthly quota: {}", format_tokens(quota_tokens));
87+
println!("Tokens saved (lifetime): {}", format_tokens(summary.total_saved));
88+
println!("Quota preserved: {:.1}%", quota_pct);
89+
println!();
90+
println!("Note: Heuristic estimate based on ~44K tokens/5h (Pro baseline)");
91+
println!(" Actual limits use rolling 5-hour windows, not monthly caps.");
92+
}
93+
7194
Ok(())
7295
}
7396

src/main.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,12 @@ enum Commands {
253253
/// Show recent command history
254254
#[arg(short = 'H', long)]
255255
history: bool,
256+
/// Show monthly quota savings estimate
257+
#[arg(short, long)]
258+
quota: bool,
259+
/// Subscription tier for quota calculation: pro, 5x, 20x
260+
#[arg(short, long, default_value = "20x", requires = "quota")]
261+
tier: String,
256262
},
257263

258264
/// Show or create configuration file
@@ -631,8 +637,8 @@ fn main() -> Result<()> {
631637
}
632638
}
633639

634-
Commands::Gain { graph, history } => {
635-
gain::run(graph, history, cli.verbose)?;
640+
Commands::Gain { graph, history, quota, tier } => {
641+
gain::run(graph, history, quota, &tier, cli.verbose)?;
636642
}
637643

638644
Commands::Config { create } => {

0 commit comments

Comments
 (0)