mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-18 06:34:26 +01:00
feat: Add command goose update to update goose CLI version (#1308)
Co-authored-by: Alex Hancock <alexhancock@block.xyz>
This commit is contained in:
@@ -2,3 +2,4 @@ pub mod agent_version;
|
||||
pub mod configure;
|
||||
pub mod info;
|
||||
pub mod mcp;
|
||||
pub mod update;
|
||||
|
||||
34
crates/goose-cli/src/commands/update.rs
Normal file
34
crates/goose-cli/src/commands/update.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
use std::process::Command;
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
const DOWNLOAD_SCRIPT_URL: &str =
|
||||
"https://github.com/block/goose/releases/download/stable/download_cli.sh";
|
||||
|
||||
pub fn update(canary: bool, reconfigure: bool) -> Result<()> {
|
||||
// Get the download script from github
|
||||
let curl_output = Command::new("curl")
|
||||
.arg("-fsSL")
|
||||
.arg(DOWNLOAD_SCRIPT_URL)
|
||||
.output()?;
|
||||
|
||||
if !curl_output.status.success() {
|
||||
anyhow::bail!(
|
||||
"Failed to download update script: {}",
|
||||
std::str::from_utf8(&curl_output.stderr)?
|
||||
);
|
||||
}
|
||||
|
||||
let shell_str = std::str::from_utf8(&curl_output.stdout)?;
|
||||
|
||||
let update = Command::new("bash")
|
||||
.arg("-c")
|
||||
.arg(shell_str)
|
||||
.env("CANARY", canary.to_string())
|
||||
.env("CONFIGURE", reconfigure.to_string())
|
||||
.spawn()?;
|
||||
|
||||
update.wait_with_output()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -157,6 +157,23 @@ enum Command {
|
||||
|
||||
/// List available agent versions
|
||||
Agents(AgentCommand),
|
||||
|
||||
/// Update the Goose CLI version
|
||||
#[command(about = "Update the goose CLI version")]
|
||||
Update {
|
||||
/// Update to canary version
|
||||
#[arg(
|
||||
short,
|
||||
long,
|
||||
help = "Update to canary version",
|
||||
long_help = "Update to the latest canary version of the goose CLI, otherwise updates to the latest stable version."
|
||||
)]
|
||||
canary: bool,
|
||||
|
||||
/// Enforce to re-configure Goose during update
|
||||
#[arg(short, long, help = "Enforce to re-configure goose during update")]
|
||||
reconfigure: bool,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(clap::ValueEnum, Clone, Debug)]
|
||||
@@ -234,6 +251,13 @@ async fn main() -> Result<()> {
|
||||
cmd.run()?;
|
||||
return Ok(());
|
||||
}
|
||||
Some(Command::Update {
|
||||
canary,
|
||||
reconfigure,
|
||||
}) => {
|
||||
goose_cli::commands::update::update(canary, reconfigure)?;
|
||||
return Ok(());
|
||||
}
|
||||
None => {
|
||||
Cli::command().print_help()?;
|
||||
println!();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
sidebar_position: 2
|
||||
---
|
||||
|
||||
# Updating Goose
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
@@ -12,10 +13,15 @@ import Link from "@docusaurus/Link";
|
||||
To update Goose to the latest stable version, reinstall using the instructions below
|
||||
:::
|
||||
|
||||
|
||||
<Tabs groupId="interface">
|
||||
<TabItem value="cli" label="Goose CLI" default>
|
||||
You can update Goose by running the [installation](/docs/getting-started/installation) script again:
|
||||
You can update Goose by simply running:
|
||||
|
||||
```sh
|
||||
goose update
|
||||
```
|
||||
|
||||
Or you can run the [installation](/docs/getting-started/installation) script again:
|
||||
|
||||
```sh
|
||||
curl -fsSL https://github.com/block/goose/releases/download/stable/download_cli.sh | CONFIGURE=false bash
|
||||
@@ -49,4 +55,3 @@ To update Goose to the latest stable version, reinstall using the instructions b
|
||||
</Tabs>
|
||||
|
||||
All configuration settings will remain the same, with Goose updated to the latest version.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user