(
target: Option<String>,
method: Option<String>,
)
| 2634 | } |
| 2635 | |
| 2636 | async 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 | |
| 2673 | async fn handle_uninstall_command( |
| 2674 | keep_config: bool, |
no test coverage detected