Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add command goose update to update goose CLI version #1308

Merged
merged 5 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/goose-cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ pub mod agent_version;
pub mod configure;
pub mod info;
pub mod mcp;
pub mod update;
34 changes: 34 additions & 0 deletions crates/goose-cli/src/commands/update.rs
Original file line number Diff line number Diff line change
@@ -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(())
}
24 changes: 24 additions & 0 deletions crates/goose-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,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)]
Expand Down Expand Up @@ -220,6 +237,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!();
Expand Down
11 changes: 8 additions & 3 deletions documentation/docs/guides/updating-goose.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
sidebar_position: 2
---

# Updating Goose

import Tabs from '@theme/Tabs';
Expand All @@ -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
Expand Down Expand Up @@ -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.

Loading