mirror of
https://github.com/aaif-goose/goose.git
synced 2026-07-03 14:10:03 +02:00
feat(cli): add subcommand completion to generate various shell completions (#6313)
Signed-off-by: Sai Karthik <kskarthik@disroot.org>
This commit is contained in:
Generated
+10
@@ -1430,6 +1430,15 @@ dependencies = [
|
||||
"terminal_size",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_complete"
|
||||
version = "4.5.62"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "004eef6b14ce34759aa7de4aea3217e368f463f46a3ed3764ca4b5a4404003b4"
|
||||
dependencies = [
|
||||
"clap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.49"
|
||||
@@ -3078,6 +3087,7 @@ dependencies = [
|
||||
"bat",
|
||||
"chrono",
|
||||
"clap",
|
||||
"clap_complete",
|
||||
"cliclack",
|
||||
"console 0.16.2",
|
||||
"dotenvy",
|
||||
|
||||
@@ -61,6 +61,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"] }
|
||||
|
||||
@@ -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::{
|
||||
@@ -855,6 +855,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)]
|
||||
@@ -962,6 +968,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",
|
||||
};
|
||||
|
||||
@@ -972,6 +979,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 }) => {
|
||||
|
||||
Reference in New Issue
Block a user