Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/redisctl/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ pub enum ProfileCommands {
#[command(visible_alias = "ls", visible_alias = "l")]
List,

/// Show the path to the configuration file
Path,

/// Show details of a specific profile
#[command(visible_alias = "sh", visible_alias = "get")]
Show {
Expand Down
20 changes: 19 additions & 1 deletion crates/redisctl/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ fn format_command(command: &Commands) -> String {
use cli::ProfileCommands::*;
match cmd {
List => "profile list".to_string(),
Path => "profile path".to_string(),
Show { name } => format!("profile show {}", name),
Set { name, .. } => format!("profile set {} [credentials redacted]", name),
Remove { name } => format!("profile remove {}", name),
Expand Down Expand Up @@ -275,6 +276,12 @@ async fn execute_profile_command(
let profiles = conn_mgr.config.list_profiles();
trace!("Found {} profiles", profiles.len());

// Show config file path at the top
if let Ok(config_path) = config::Config::config_path() {
println!("Configuration file: {}", config_path.display());
println!();
}

if profiles.is_empty() {
info!("No profiles configured");
println!("No profiles configured.");
Expand Down Expand Up @@ -322,6 +329,12 @@ async fn execute_profile_command(
Ok(())
}

Path => {
let config_path = config::Config::config_path()?;
println!("{}", config_path.display());
Ok(())
}

Show { name } => match conn_mgr.config.profiles.get(name) {
Some(profile) => {
println!("Profile: {}", name);
Expand Down Expand Up @@ -453,7 +466,12 @@ async fn execute_profile_command(
// Save the configuration
config.save().context("Failed to save configuration")?;

println!("Profile '{}' saved successfully.", name);
if let Ok(config_path) = config::Config::config_path() {
println!("Profile '{}' saved successfully to:", name);
println!(" {}", config_path.display());
} else {
println!("Profile '{}' saved successfully.", name);
}

// Ask if this should be the default profile
if config.default_profile.is_none() || config.profiles.len() == 1 {
Expand Down
Loading