MCPcopy Create free account
hub / github.com/GCWing/BitFun / run_cli

Function run_cli

src/apps/cli/src/main.rs:529–717  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

527// ======================== Main ========================
528
529async fn run_cli() -> Result<()> {
530 let cli = Cli::parse();
531
532 let is_tui_mode = matches!(cli.command, None | Some(Commands::Chat { .. }));
533 let is_exec_mode = matches!(cli.command, Some(Commands::Exec { .. }));
534 let file_log_level = logging::default_log_level(cli.verbose);
535 let stderr_log_level = if cli.verbose {
536 tracing::Level::TRACE
537 } else {
538 tracing::Level::ERROR
539 };
540
541 if is_tui_mode || is_exec_mode {
542 logging::init_file_logging(file_log_level);
543 } else {
544 tracing_subscriber::fmt()
545 .with_max_level(stderr_log_level)
546 .with_writer(std::io::stderr)
547 .with_ansi(false)
548 .with_target(false)
549 .init();
550 }
551
552 let config = CliConfig::load().unwrap_or_else(|e| {
553 if !is_tui_mode {
554 eprintln!("Warning: Failed to load config: {}", e);
555 eprintln!("Using default configuration");
556 }
557 CliConfig::default()
558 });
559
560 match cli.command {
561 Some(Commands::Chat { agent }) => {
562 // Interactive mode with startup page, scoped to the current directory.
563 run_interactive(config, agent, ".".to_string()).await?;
564 }
565
566 Some(Commands::Exec {
567 message,
568 agent,
569 continue_last,
570 resume,
571 session,
572 session_id,
573 fork_session,
574 output_format,
575 output_patch,
576 confirm,
577 }) => {
578 root_handlers::handle_exec_command(
579 config,
580 root_handlers::ExecCommandArgs {
581 message,
582 agent,
583 continue_last,
584 resume,
585 session,
586 session_id,

Callers 1

mainFunction · 0.85

Calls 15

parseFunction · 0.85
default_log_levelFunction · 0.85
init_file_loggingFunction · 0.85
run_interactiveFunction · 0.85
handle_exec_commandFunction · 0.85
handle_session_actionFunction · 0.85
print_agentsFunction · 0.85
print_modelsFunction · 0.85
set_default_modelFunction · 0.85
print_mcp_serversFunction · 0.85
set_mcp_server_enabledFunction · 0.85

Tested by

no test coverage detected