fix: shows the correct config file update path with cli configure (#5195)
Signed-off-by: Anthony D. Mays <anthony@morganlatimer.com>
This commit is contained in:
@@ -10,6 +10,7 @@ use goose::config::extensions::{
|
|||||||
get_all_extension_names, get_all_extensions, get_enabled_extensions, get_extension_by_name,
|
get_all_extension_names, get_all_extensions, get_enabled_extensions, get_extension_by_name,
|
||||||
name_to_key, remove_extension, set_extension, set_extension_enabled,
|
name_to_key, remove_extension, set_extension, set_extension_enabled,
|
||||||
};
|
};
|
||||||
|
use goose::config::paths::Paths;
|
||||||
use goose::config::permission::PermissionLevel;
|
use goose::config::permission::PermissionLevel;
|
||||||
use goose::config::signup_tetrate::TetrateAuth;
|
use goose::config::signup_tetrate::TetrateAuth;
|
||||||
use goose::config::{
|
use goose::config::{
|
||||||
@@ -195,15 +196,17 @@ pub async fn handle_configure() -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
|
let config_dir = Paths::config_dir().display().to_string();
|
||||||
|
|
||||||
println!();
|
println!();
|
||||||
println!(
|
println!(
|
||||||
"{}",
|
"{}",
|
||||||
style("This will update your existing config file").dim()
|
style("This will update your existing config files").dim()
|
||||||
);
|
);
|
||||||
println!(
|
println!(
|
||||||
"{} {}",
|
"{} {}",
|
||||||
style(" if you prefer, you can edit it directly at").dim(),
|
style(" if you prefer, you can edit them directly at").dim(),
|
||||||
config.path()
|
config_dir
|
||||||
);
|
);
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
@@ -486,7 +489,7 @@ pub async fn configure_provider_dialog() -> anyhow::Result<bool> {
|
|||||||
} else {
|
} else {
|
||||||
config.set_param(&key.name, Value::String(env_value))?;
|
config.set_param(&key.name, Value::String(env_value))?;
|
||||||
}
|
}
|
||||||
let _ = cliclack::log::info(format!("Saved {} to config file", key.name));
|
let _ = cliclack::log::info(format!("Saved {} to {}", key.name, config.path()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
@@ -648,7 +651,7 @@ pub async fn configure_provider_dialog() -> anyhow::Result<bool> {
|
|||||||
// Update config with new values only if the test succeeds
|
// Update config with new values only if the test succeeds
|
||||||
config.set_param("GOOSE_PROVIDER", Value::String(provider_name.to_string()))?;
|
config.set_param("GOOSE_PROVIDER", Value::String(provider_name.to_string()))?;
|
||||||
config.set_param("GOOSE_MODEL", Value::String(model.clone()))?;
|
config.set_param("GOOSE_MODEL", Value::String(model.clone()))?;
|
||||||
cliclack::outro("Configuration saved successfully")?;
|
print_config_file_saved()?;
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
@@ -709,7 +712,11 @@ pub fn toggle_extensions_dialog() -> anyhow::Result<()> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
cliclack::outro("Extension settings updated successfully")?;
|
let config = Config::global();
|
||||||
|
cliclack::outro(format!(
|
||||||
|
"Extension settings saved successfully to {}",
|
||||||
|
config.path()
|
||||||
|
))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1123,6 +1130,8 @@ pub fn configure_extensions_dialog() -> anyhow::Result<()> {
|
|||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
print_config_file_saved()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1178,6 +1187,8 @@ pub fn remove_extension_dialog() -> anyhow::Result<()> {
|
|||||||
cliclack::outro(format!("Removed {} extension", style(name).green()))?;
|
cliclack::outro(format!("Removed {} extension", style(name).green()))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print_config_file_saved()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1216,6 +1227,8 @@ pub async fn configure_settings_dialog() -> anyhow::Result<()> {
|
|||||||
)
|
)
|
||||||
.interact()?;
|
.interact()?;
|
||||||
|
|
||||||
|
let mut should_print_config_path = true;
|
||||||
|
|
||||||
match setting_type {
|
match setting_type {
|
||||||
"goose_mode" => {
|
"goose_mode" => {
|
||||||
configure_goose_mode_dialog()?;
|
configure_goose_mode_dialog()?;
|
||||||
@@ -1225,6 +1238,8 @@ pub async fn configure_settings_dialog() -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
"tool_permission" => {
|
"tool_permission" => {
|
||||||
configure_tool_permissions_dialog().await.and(Ok(()))?;
|
configure_tool_permissions_dialog().await.and(Ok(()))?;
|
||||||
|
// No need to print config file path since it's already handled.
|
||||||
|
should_print_config_path = false;
|
||||||
}
|
}
|
||||||
"tool_output" => {
|
"tool_output" => {
|
||||||
configure_tool_output_dialog()?;
|
configure_tool_output_dialog()?;
|
||||||
@@ -1241,6 +1256,10 @@ pub async fn configure_settings_dialog() -> anyhow::Result<()> {
|
|||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if should_print_config_path {
|
||||||
|
print_config_file_saved()?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1547,6 +1566,11 @@ pub async fn configure_tool_permissions_dialog() -> anyhow::Result<()> {
|
|||||||
tool.name, permission_label
|
tool.name, permission_label
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
|
cliclack::outro(format!(
|
||||||
|
"Changes saved to {}",
|
||||||
|
permission_manager.get_config_path().display()
|
||||||
|
))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1893,5 +1917,18 @@ pub fn configure_custom_provider_dialog() -> anyhow::Result<()> {
|
|||||||
"add" => add_provider(),
|
"add" => add_provider(),
|
||||||
"remove" => remove_provider(),
|
"remove" => remove_provider(),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}?;
|
||||||
|
|
||||||
|
print_config_file_saved()?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn print_config_file_saved() -> anyhow::Result<()> {
|
||||||
|
let config = Config::global();
|
||||||
|
cliclack::outro(format!(
|
||||||
|
"Configuration saved successfully to {}",
|
||||||
|
config.path()
|
||||||
|
))?;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ pub fn handle_info(verbose: bool) -> Result<()> {
|
|||||||
|
|
||||||
// Get paths using a stored reference to the global config
|
// Get paths using a stored reference to the global config
|
||||||
let config = Config::global();
|
let config = Config::global();
|
||||||
let config_file = config.path();
|
let config_dir = Paths::config_dir().display().to_string();
|
||||||
|
|
||||||
// Define the labels and their corresponding path values once.
|
// Define the labels and their corresponding path values once.
|
||||||
let paths = [
|
let paths = [
|
||||||
("Config file:", config_file.to_string()),
|
("Config dir:", config_dir),
|
||||||
("Sessions dir:", sessions_dir.display().to_string()),
|
("Sessions dir:", sessions_dir.display().to_string()),
|
||||||
("Logs dir:", logs_dir.display().to_string()),
|
("Logs dir:", logs_dir.display().to_string()),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -91,6 +91,11 @@ impl PermissionManager {
|
|||||||
self.get_permission(SMART_APPROVE_PERMISSION, principal_name)
|
self.get_permission(SMART_APPROVE_PERMISSION, principal_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Retrieves the config file path.
|
||||||
|
pub fn get_config_path(&self) -> &Path {
|
||||||
|
self.config_path.as_path()
|
||||||
|
}
|
||||||
|
|
||||||
/// Helper function to retrieve the permission level for a specific permission category and tool.
|
/// Helper function to retrieve the permission level for a specific permission category and tool.
|
||||||
fn get_permission(&self, name: &str, principal_name: &str) -> Option<PermissionLevel> {
|
fn get_permission(&self, name: &str, principal_name: &str) -> Option<PermissionLevel> {
|
||||||
// Check if the permission category exists in the map
|
// Check if the permission category exists in the map
|
||||||
|
|||||||
Reference in New Issue
Block a user