MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / run_upgrade_process

Function run_upgrade_process

crates/opencode-cli/src/main.rs:2588–2623  ·  view source on GitHub ↗
(method: InstallMethod, target: &str)

Source from the content-addressed store, hash-verified

2586}
2587
2588fn run_upgrade_process(method: InstallMethod, target: &str) -> anyhow::Result<()> {
2589 let status = match method {
2590 InstallMethod::Curl => ProcessCommand::new("sh")
2591 .arg("-c")
2592 .arg("curl -fsSL https://opencode.ai/install | bash")
2593 .env("VERSION", target)
2594 .status(),
2595 InstallMethod::Npm => ProcessCommand::new("npm")
2596 .args(["install", "-g", &format!("opencode-ai@{}", target)])
2597 .status(),
2598 InstallMethod::Pnpm => ProcessCommand::new("pnpm")
2599 .args(["install", "-g", &format!("opencode-ai@{}", target)])
2600 .status(),
2601 InstallMethod::Bun => ProcessCommand::new("bun")
2602 .args(["install", "-g", &format!("opencode-ai@{}", target)])
2603 .status(),
2604 InstallMethod::Brew => ProcessCommand::new("brew")
2605 .args(["upgrade", "opencode"])
2606 .status(),
2607 InstallMethod::Choco => ProcessCommand::new("choco")
2608 .args(["upgrade", "opencode", "--version", target, "-y"])
2609 .status(),
2610 InstallMethod::Scoop => ProcessCommand::new("scoop")
2611 .args(["install", &format!("opencode@{}", target)])
2612 .status(),
2613 InstallMethod::Unknown => {
2614 anyhow::bail!("Unknown install method; pass --method to specify one explicitly.")
2615 }
2616 }
2617 .map_err(|e| anyhow::anyhow!("Failed to execute upgrade command: {}", e))?;
2618
2619 if !status.success() {
2620 anyhow::bail!("Upgrade command exited with status {}", status);
2621 }
2622 Ok(())
2623}
2624
2625fn prompt_yes_no(question: &str) -> anyhow::Result<bool> {
2626 print!("{} [y/N]: ", question);

Callers 1

handle_upgrade_commandFunction · 0.85

Calls 3

newFunction · 0.85
statusMethod · 0.45
successMethod · 0.45

Tested by

no test coverage detected