mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-18 14:44:21 +01:00
feat: allow for multiple values in cli options for adding extensions (#1070)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user