MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / handle_upgrade_command

Function handle_upgrade_command

crates/opencode-cli/src/main.rs:2636–2671  ·  view source on GitHub ↗
(
    target: Option<String>,
    method: Option<String>,
)

Source from the content-addressed store, hash-verified

2634}
2635
2636async fn handle_upgrade_command(
2637 target: Option<String>,
2638 method: Option<String>,
2639) -> anyhow::Result<()> {
2640 let detected = detect_install_method();
2641 let method = method
2642 .as_deref()
2643 .map(InstallMethod::parse)
2644 .unwrap_or(detected);
2645
2646 println!("Using method: {}", method.as_str());
2647
2648 if method == InstallMethod::Unknown
2649 && !prompt_yes_no("Installation method is unknown. Continue anyway?")?
2650 {
2651 println!("Cancelled.");
2652 return Ok(());
2653 }
2654
2655 let target = if let Some(target) = target {
2656 target.trim_start_matches('v').to_string()
2657 } else {
2658 latest_version(method).await?
2659 };
2660
2661 let current = env!("CARGO_PKG_VERSION").trim_start_matches('v');
2662 if current == target {
2663 println!("opencode upgrade skipped: {} is already installed", target);
2664 return Ok(());
2665 }
2666
2667 println!("From {} -> {}", current, target);
2668 run_upgrade_process(method, &target)?;
2669 println!("Upgrade complete.");
2670 Ok(())
2671}
2672
2673async fn handle_uninstall_command(
2674 keep_config: bool,

Callers 1

mainFunction · 0.85

Calls 4

detect_install_methodFunction · 0.85
prompt_yes_noFunction · 0.85
latest_versionFunction · 0.85
run_upgrade_processFunction · 0.85

Tested by

no test coverage detected