@sigit / si Mirror · read-only
Fork 0

Mirror of github.com/getsigit/si.

Mirrored from https://github.com/getsigit/si.git

Synced Nov 24, 09:30 UTC

1 mod cli;
2 mod commands;
3 mod config;
4 mod context;
5 mod credential;
6 mod git;
7 mod mcp;
8 mod ui;
9
10 use {
11 anyhow::Result,
12 clap::Parser,
13 cli::{Cli, Command},
14 console::style,
15 context::Ctx,
16 sigit_si_api::Client,
17 };
18
19 #[tokio::main]
20 async fn main() {
21 tracing_subscriber::fmt()
22 .with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
23 .with_writer(std::io::stderr)
24 .init();
25
26 if let Err(e) = run().await {
27 eprintln!("{} {:#}", style("✘").red(), e);
28 std::process::exit(1);
29 }
30 }
31
32 async fn run() -> Result<()> {
33 let cli = Cli::parse();
34
35 let mut client = Client::new(cli.environment)?;
36 if let Some(token) = config::read_token(cli.environment) {
37 client = client.with_token(token);
38 }
39
40 let ctx = Ctx::new(client, cli.environment, cli.json);
41
42 match cli.command {
43 Command::Auth(command) => commands::auth::run(&ctx, command).await,
44 Command::Me => commands::me::run(&ctx).await,
45 Command::Repo(command) => commands::repo::run(&ctx, command).await,
46 Command::Pr(command) => commands::pr::run(&ctx, command).await,
47 Command::Issue(command) => commands::issue::run(&ctx, command).await,
48 Command::Code(command) => commands::code::run(&ctx, command).await,
49 Command::Run(command) => commands::run::run(&ctx, command).await,
50 Command::Site(command) => commands::site::run(&ctx, command).await,
51 Command::Status(command) => commands::status::run(&ctx, command).await,
52 Command::Hook(command) => commands::hook::run(&ctx, command).await,
53 Command::Session(command) => commands::session::run(&ctx, command).await,
54 Command::Billing(command) => commands::billing::run(&ctx, command).await,
55 Command::Models => commands::models::run(&ctx).await,
56 Command::Browse(args) => commands::browse::run(&ctx, args).await,
57 Command::Api(args) => commands::api::run(&ctx, args).await,
58 // Takes `ctx` by value: the server outlives the dispatch, serving
59 // tools over stdio until the client hangs up.
60 Command::Mcp(args) => mcp::run(ctx, args).await,
61 }
62 }