Skip to main content

tokenusage/
lib.rs

1mod cli;
2mod config;
3mod gui;
4mod output;
5mod pipeline;
6mod types;
7
8use anyhow::Result;
9use clap::Parser;
10
11use crate::cli::{Cli, Commands, DailyArgs, normalize_cli_args};
12
13pub async fn run() -> Result<()> {
14    let cli = Cli::parse_from(normalize_cli_args(std::env::args().collect()));
15
16    let command = cli.command.unwrap_or(Commands::Daily(DailyArgs::default()));
17    let command = config::apply_config(command)?;
18
19    match command {
20        Commands::Daily(args) => pipeline::run_daily(args).await,
21        Commands::Codex(mut args) => {
22            args.common.no_claude = true;
23            args.common.no_codex = false;
24            pipeline::run_daily(args).await
25        }
26        Commands::Claude(mut args) => {
27            args.common.no_codex = true;
28            args.common.no_claude = false;
29            pipeline::run_daily(args).await
30        }
31        Commands::Monthly(args) => pipeline::run_monthly(args).await,
32        Commands::Weekly(args) => pipeline::run_weekly(args).await,
33        Commands::Session(args) => pipeline::run_session(args).await,
34        Commands::Blocks(args) => pipeline::run_blocks(args).await,
35        Commands::Live(args) => pipeline::run_blocks(args.into()).await,
36        Commands::Statusline(args) => pipeline::run_statusline(args).await,
37        Commands::Gui(args) => gui::run_gui(args),
38    }
39}