Skip to main content

tokenusage/
lib.rs

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