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",
|
"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]]
|
[[package]]
|
||||||
name = "clap_derive"
|
name = "clap_derive"
|
||||||
version = "4.5.49"
|
version = "4.5.49"
|
||||||
@@ -3078,6 +3087,7 @@ dependencies = [
|
|||||||
"bat",
|
"bat",
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
|
"clap_complete",
|
||||||
"cliclack",
|
"cliclack",
|
||||||
"console 0.16.2",
|
"console 0.16.2",
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ anstream = "0.6.18"
|
|||||||
url = "2.5.7"
|
url = "2.5.7"
|
||||||
open = "5.3.2"
|
open = "5.3.2"
|
||||||
urlencoding = "2.1"
|
urlencoding = "2.1"
|
||||||
|
clap_complete = "4.5.62"
|
||||||
|
|
||||||
[target.'cfg(target_os = "windows")'.dependencies]
|
[target.'cfg(target_os = "windows")'.dependencies]
|
||||||
winapi = { version = "0.3", features = ["wincred"] }
|
winapi = { version = "0.3", features = ["wincred"] }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use anyhow::Result;
|
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::config::{Config, ExtensionConfig};
|
||||||
use goose_mcp::mcp_server_runner::{serve, McpCommand};
|
use goose_mcp::mcp_server_runner::{serve, McpCommand};
|
||||||
use goose_mcp::{
|
use goose_mcp::{
|
||||||
@@ -855,6 +855,12 @@ enum Command {
|
|||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
command: TermCommand,
|
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)]
|
#[derive(Subcommand)]
|
||||||
@@ -962,6 +968,7 @@ pub async fn cli() -> anyhow::Result<()> {
|
|||||||
Some(Command::Recipe { .. }) => "recipe",
|
Some(Command::Recipe { .. }) => "recipe",
|
||||||
Some(Command::Web { .. }) => "web",
|
Some(Command::Web { .. }) => "web",
|
||||||
Some(Command::Term { .. }) => "term",
|
Some(Command::Term { .. }) => "term",
|
||||||
|
Some(Command::Completion { .. }) => "completion",
|
||||||
None => "default_session",
|
None => "default_session",
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -972,6 +979,11 @@ pub async fn cli() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
match cli.command {
|
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::Configure {}) => handle_configure().await?,
|
||||||
Some(Command::Info { verbose }) => handle_info(verbose)?,
|
Some(Command::Info { verbose }) => handle_info(verbose)?,
|
||||||
Some(Command::Mcp { server }) => {
|
Some(Command::Mcp { server }) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user