Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify operation result for working with aliases #1748

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 9 additions & 12 deletions atuin/src/command/client/config/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ impl Cmd {
let found: Vec<Alias> = aliases.into_iter().filter(|a| a.name == name).collect();

if found.is_empty() {
println!("Aliasing {name}={value}");
println!("Aliasing '{name}={value}'.");
} else {
println!(
"Overwriting alias {name}={} with {name}={value}",
"Overwriting alias '{name}={}' with '{name}={value}'.",
found[0].value
);
}
Expand All @@ -43,16 +43,13 @@ impl Cmd {
}

async fn delete(&self, store: AliasStore, name: String) -> Result<()> {
let aliases = store.aliases().await?;
let found = aliases.into_iter().any(|a| a.name == name);

if !found {
eprintln!("Alias not found - \"{name}\" - could not delete");
return Ok(());
}

store.delete(&name).await?;

let mut aliases = store.aliases().await?.into_iter();
if let Some(alias) = aliases.find(|alias| alias.name == name) {
println!("Deleting '{name}={}'.", alias.value);
store.delete(&name).await?;
} else {
eprintln!("Cannot delete '{name}': Alias not set.");
};
Ok(())
}

Expand Down