mod client;
mod cmd;
mod config;
mod keyring_store;
mod output;
use anyhow::Result;
use clap::{Parser, Subcommand};
use cmd::auth::AuthCmd;
use cmd::batch::BatchCmd;
use cmd::bug_report::BugReportCmd;
use cmd::indicator::IndicatorCmd;
use cmd::symbols::SymbolsCmd;
use cmd::usage::UsageCmd;
#[derive(Debug, Parser)]
#[command(name = "tranc", version, about, long_about = None)]
struct Cli {
#[arg(long, global = true, env = "TRANC_API_URL")]
api_url: Option<String>,
#[arg(long, global = true)]
pretty: bool,
#[command(subcommand)]
command: Commands,
}
#[derive(Debug, Subcommand)]
enum Commands {
Auth(AuthCmd),
Symbols(SymbolsCmd),
Indicator(IndicatorCmd),
Batch(BatchCmd),
Usage(UsageCmd),
BugReport(BugReportCmd),
}
#[tokio::main]
async fn main() -> Result<()> {
let cli = Cli::parse();
let api_url = cli
.api_url
.unwrap_or_else(|| "https://api.tranc.ai".to_string());
let pretty = cli.pretty;
match cli.command {
Commands::Auth(cmd) => cmd.run(&api_url, pretty).await,
Commands::Symbols(cmd) => cmd.run(&api_url, pretty).await,
Commands::Indicator(cmd) => cmd.run(&api_url, pretty).await,
Commands::Batch(cmd) => cmd.run(&api_url, pretty).await,
Commands::Usage(cmd) => cmd.run(&api_url, pretty).await,
Commands::BugReport(cmd) => cmd.run(),
}
}