feat: allow for multiple values in cli options for adding extensions (#1070)

This commit is contained in:
Zaki Ali
2025-02-06 09:54:02 -08:00
committed by GitHub
parent 7d9a0a8fea
commit 8eddc40b94
3 changed files with 35 additions and 23 deletions

View File

@@ -15,8 +15,8 @@ use mcp_client::transport::Error as McpClientError;
pub async fn build_session(
name: Option<String>,
resume: bool,
extension: Option<String>,
builtin: Option<String>,
extensions: Vec<String>,
builtins: Vec<String>,
) -> Session<'static> {
// Load config and get provider/model
let config = Config::global();
@@ -64,8 +64,8 @@ pub async fn build_session(
}
}
// Add extension if provided
if let Some(extension_str) = extension {
// Add extensions if provided
for extension_str in extensions {
let mut parts: Vec<&str> = extension_str.split_whitespace().collect();
let mut envs = std::collections::HashMap::new();
@@ -104,8 +104,8 @@ pub async fn build_session(
});
}
// Add builtin extension if provided
if let Some(name) = builtin {
// Add builtin extensions
for name in builtins {
let config = ExtensionConfig::Builtin { name };
agent.add_extension(config).await.unwrap_or_else(|e| {
eprintln!("Failed to start builtin extension: {}", e);

View File

@@ -65,23 +65,25 @@ enum Command {
)]
resume: bool,
/// Add a stdio extension with environment variables and command
/// Add stdio extensions with environment variables and commands
#[arg(
long = "with-extension",
value_name = "COMMAND",
help = "Add a stdio extension (e.g., 'GITHUB_TOKEN=xyz npx -y @modelcontextprotocol/server-github')",
long_help = "Add a stdio extension from a full command with environment variables. Format: 'ENV1=val1 ENV2=val2 command args...'"
help = "Add stdio extensions (can be specified multiple times)",
long_help = "Add stdio extensions from full commands with environment variables. Can be specified multiple times. Format: 'ENV1=val1 ENV2=val2 command args...'",
action = clap::ArgAction::Append
)]
extension: Option<String>,
extension: Vec<String>,
/// Add a builtin extension by name
/// Add builtin extensions by name
#[arg(
long = "with-builtin",
value_name = "NAME",
help = "Add a builtin extension by name (e.g., 'developer')",
long_help = "Add a builtin extension that is bundled with goose by specifying its name"
help = "Add builtin extensions by name (e.g., 'developer' or multiple: 'developer,github')",
long_help = "Add one or more builtin extensions that are bundled with goose by specifying their names, comma-separated",
value_delimiter = ','
)]
builtin: Option<String>,
builtin: Vec<String>,
},
/// Execute commands from an instruction file
@@ -128,23 +130,25 @@ enum Command {
)]
resume: bool,
/// Add a stdio extension with environment variables and command
/// Add stdio extensions with environment variables and commands
#[arg(
long = "with-extension",
value_name = "COMMAND",
help = "Add a stdio extension with environment variables and command (e.g., 'GITHUB_TOKEN=xyz npx -y @modelcontextprotocol/server-github')",
long_help = "Add a stdio extension with environment variables and command. Format: 'ENV1=val1 ENV2=val2 command args...'"
help = "Add stdio extensions (can be specified multiple times)",
long_help = "Add stdio extensions from full commands with environment variables. Can be specified multiple times. Format: 'ENV1=val1 ENV2=val2 command args...'",
action = clap::ArgAction::Append
)]
extension: Option<String>,
extension: Vec<String>,
/// Add a builtin extension by name
/// Add builtin extensions by name
#[arg(
long = "with-builtin",
value_name = "NAME",
help = "Add a builtin extension by name (e.g., 'developer')",
long_help = "Add a builtin extension that is compiled into goose by specifying its name"
help = "Add builtin extensions by name (e.g., 'developer' or multiple: 'developer,github')",
long_help = "Add one or more builtin extensions that are bundled with goose by specifying their names, comma-separated",
value_delimiter = ','
)]
builtin: Option<String>,
builtin: Vec<String>,
},
/// List available agent versions