Skip to content
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
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/goose-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ anstream = "0.6.18"
url = "2.5.7"
open = "5.3.2"
urlencoding = "2.1"
clap_complete = "4.5.62"

[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3", features = ["wincred"] }
Expand Down
16 changes: 14 additions & 2 deletions crates/goose-cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Result;
use clap::{Args, Parser, Subcommand};

use clap::{Args, CommandFactory, Parser, Subcommand};
use clap_complete::{generate, Shell as ClapShell};
use goose::config::{Config, ExtensionConfig};
use goose_mcp::mcp_server_runner::{serve, McpCommand};
use goose_mcp::{
Expand Down Expand Up @@ -865,6 +865,12 @@ enum Command {
#[command(subcommand)]
command: TermCommand,
},
/// Generate completions for various shells
#[command(about = "Generate the autocompletion script for the specified shell")]
Completion {
#[arg(value_enum)]
shell: ClapShell,
},
}

#[derive(Subcommand)]
Expand Down Expand Up @@ -972,6 +978,7 @@ pub async fn cli() -> anyhow::Result<()> {
Some(Command::Recipe { .. }) => "recipe",
Some(Command::Web { .. }) => "web",
Some(Command::Term { .. }) => "term",
Some(Command::Completion { .. }) => "completion",
None => "default_session",
};

Expand All @@ -982,6 +989,11 @@ pub async fn cli() -> anyhow::Result<()> {
);

match cli.command {
Some(Command::Completion { shell }) => {
let mut cmd = Cli::command();
let bin_name = cmd.get_name().to_string();
generate(shell, &mut cmd, bin_name, &mut std::io::stdout());
}
Some(Command::Configure {}) => handle_configure().await?,
Some(Command::Info { verbose }) => handle_info(verbose)?,
Some(Command::Mcp { server }) => {
Expand Down