Skip to content

Commit f3b25c2

Browse files
feat: add profile path command and improve config visibility (#253)
- Added 'profile path' command to show config file location - Profile list now shows config file path at the top - Profile set shows where the config was saved - Makes configuration more discoverable for users Addresses #251
1 parent 4d5f3a2 commit f3b25c2

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

crates/redisctl/src/cli.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ pub enum ProfileCommands {
154154
#[command(visible_alias = "ls", visible_alias = "l")]
155155
List,
156156

157+
/// Show the path to the configuration file
158+
Path,
159+
157160
/// Show details of a specific profile
158161
#[command(visible_alias = "sh", visible_alias = "get")]
159162
Show {

crates/redisctl/src/main.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ fn format_command(command: &Commands) -> String {
155155
use cli::ProfileCommands::*;
156156
match cmd {
157157
List => "profile list".to_string(),
158+
Path => "profile path".to_string(),
158159
Show { name } => format!("profile show {}", name),
159160
Set { name, .. } => format!("profile set {} [credentials redacted]", name),
160161
Remove { name } => format!("profile remove {}", name),
@@ -275,6 +276,12 @@ async fn execute_profile_command(
275276
let profiles = conn_mgr.config.list_profiles();
276277
trace!("Found {} profiles", profiles.len());
277278

279+
// Show config file path at the top
280+
if let Ok(config_path) = config::Config::config_path() {
281+
println!("Configuration file: {}", config_path.display());
282+
println!();
283+
}
284+
278285
if profiles.is_empty() {
279286
info!("No profiles configured");
280287
println!("No profiles configured.");
@@ -322,6 +329,12 @@ async fn execute_profile_command(
322329
Ok(())
323330
}
324331

332+
Path => {
333+
let config_path = config::Config::config_path()?;
334+
println!("{}", config_path.display());
335+
Ok(())
336+
}
337+
325338
Show { name } => match conn_mgr.config.profiles.get(name) {
326339
Some(profile) => {
327340
println!("Profile: {}", name);
@@ -453,7 +466,12 @@ async fn execute_profile_command(
453466
// Save the configuration
454467
config.save().context("Failed to save configuration")?;
455468

456-
println!("Profile '{}' saved successfully.", name);
469+
if let Ok(config_path) = config::Config::config_path() {
470+
println!("Profile '{}' saved successfully to:", name);
471+
println!(" {}", config_path.display());
472+
} else {
473+
println!("Profile '{}' saved successfully.", name);
474+
}
457475

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

0 commit comments

Comments
 (0)