mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-17 22:24:21 +01:00
feat: add goose info command to display directories in use + config (#1239)
This commit is contained in:
63
crates/goose-cli/src/commands/info.rs
Normal file
63
crates/goose-cli/src/commands/info.rs
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
use anyhow::Result;
|
||||||
|
use console::style;
|
||||||
|
use etcetera::{choose_app_strategy, AppStrategy};
|
||||||
|
use goose::config::Config;
|
||||||
|
use serde_yaml;
|
||||||
|
|
||||||
|
fn print_aligned(label: &str, value: &str, width: usize) {
|
||||||
|
println!(" {:<width$} {}", label, value, width = width);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn handle_info(verbose: bool) -> Result<()> {
|
||||||
|
let data_dir = choose_app_strategy(crate::APP_STRATEGY.clone())?;
|
||||||
|
let logs_dir = data_dir.in_data_dir("logs");
|
||||||
|
let sessions_dir = data_dir.in_data_dir("sessions");
|
||||||
|
|
||||||
|
// Get paths using a stored reference to the global config
|
||||||
|
let config = Config::global();
|
||||||
|
let config_file = config.path();
|
||||||
|
|
||||||
|
// Define the labels and their corresponding path values once.
|
||||||
|
let paths = [
|
||||||
|
("Config file:", config_file.to_string()),
|
||||||
|
("Sessions dir:", sessions_dir.display().to_string()),
|
||||||
|
("Logs dir:", logs_dir.display().to_string()),
|
||||||
|
];
|
||||||
|
|
||||||
|
// Calculate padding: use the max length of the label plus extra space.
|
||||||
|
let basic_padding = paths.iter().map(|(l, _)| l.len()).max().unwrap_or(0) + 4;
|
||||||
|
|
||||||
|
// Print version information
|
||||||
|
println!("{}", style("Goose Version:").cyan().bold());
|
||||||
|
print_aligned("Version:", env!("CARGO_PKG_VERSION"), basic_padding);
|
||||||
|
println!();
|
||||||
|
|
||||||
|
// Print location information
|
||||||
|
println!("{}", style("Goose Locations:").cyan().bold());
|
||||||
|
for (label, path) in &paths {
|
||||||
|
print_aligned(label, path, basic_padding);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print verbose info if requested
|
||||||
|
if verbose {
|
||||||
|
println!("\n{}", style("Goose Configuration:").cyan().bold());
|
||||||
|
match config.load_values() {
|
||||||
|
Ok(values) => {
|
||||||
|
if values.is_empty() {
|
||||||
|
println!(" No configuration values set");
|
||||||
|
println!(
|
||||||
|
" Run '{}' to configure goose",
|
||||||
|
style("goose configure").cyan()
|
||||||
|
);
|
||||||
|
} else if let Ok(yaml) = serde_yaml::to_string(&values) {
|
||||||
|
for line in yaml.lines() {
|
||||||
|
println!(" {}", line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => println!(" Error loading configuration: {}", e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
pub mod agent_version;
|
pub mod agent_version;
|
||||||
pub mod configure;
|
pub mod configure;
|
||||||
|
pub mod info;
|
||||||
pub mod mcp;
|
pub mod mcp;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ use console::style;
|
|||||||
use goose::config::Config;
|
use goose::config::Config;
|
||||||
use goose_cli::commands::agent_version::AgentCommand;
|
use goose_cli::commands::agent_version::AgentCommand;
|
||||||
use goose_cli::commands::configure::handle_configure;
|
use goose_cli::commands::configure::handle_configure;
|
||||||
|
use goose_cli::commands::info::handle_info;
|
||||||
use goose_cli::commands::mcp::run_server;
|
use goose_cli::commands::mcp::run_server;
|
||||||
use goose_cli::logging::setup_logging;
|
use goose_cli::logging::setup_logging;
|
||||||
use goose_cli::session::build_session;
|
use goose_cli::session::build_session;
|
||||||
@@ -23,6 +24,14 @@ enum Command {
|
|||||||
#[command(about = "Configure Goose settings")]
|
#[command(about = "Configure Goose settings")]
|
||||||
Configure {},
|
Configure {},
|
||||||
|
|
||||||
|
/// Display Goose configuration information
|
||||||
|
#[command(about = "Display Goose information")]
|
||||||
|
Info {
|
||||||
|
/// Show verbose information including current configuration
|
||||||
|
#[arg(short, long, help = "Show verbose information including config.yaml")]
|
||||||
|
verbose: bool,
|
||||||
|
},
|
||||||
|
|
||||||
/// Manage system prompts and behaviors
|
/// Manage system prompts and behaviors
|
||||||
#[command(about = "Run one of the mcp servers bundled with goose")]
|
#[command(about = "Run one of the mcp servers bundled with goose")]
|
||||||
Mcp { name: String },
|
Mcp { name: String },
|
||||||
@@ -158,6 +167,10 @@ async fn main() -> Result<()> {
|
|||||||
let _ = handle_configure().await;
|
let _ = handle_configure().await;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
Some(Command::Info { verbose }) => {
|
||||||
|
handle_info(verbose)?;
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
Some(Command::Mcp { name }) => {
|
Some(Command::Mcp { name }) => {
|
||||||
let _ = run_server(&name).await;
|
let _ = run_server(&name).await;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,9 +98,17 @@ goose run --instructions plan.md
|
|||||||
|
|
||||||
Configure Goose settings - providers, extensions, etc.
|
Configure Goose settings - providers, extensions, etc.
|
||||||
|
|
||||||
|
**Usage:**
|
||||||
|
```bash
|
||||||
|
goose configure
|
||||||
|
```
|
||||||
|
|
||||||
|
### info [options]
|
||||||
|
Shows Goose information, where goose will load `config.yaml`, store data and logs.
|
||||||
|
|
||||||
|
- **`-v, --verbose`**: Show verbose information including config.yaml
|
||||||
|
|
||||||
**Usage:**
|
**Usage:**
|
||||||
```bash
|
```bash
|
||||||
goose configure'
|
goose info
|
||||||
```
|
```
|
||||||
Reference in New Issue
Block a user