mirror of
https://github.com/atuinsh/atuin.git
synced 2025-01-16 11:19:46 +01:00
refactor(alias): Clarify operation result for working with aliases (#1748)
This commit is contained in:
parent
6a885cf4ab
commit
cf2cbd23f0
@ -19,10 +19,10 @@ impl Cmd {
|
|||||||
let found: Vec<Alias> = aliases.into_iter().filter(|a| a.name == name).collect();
|
let found: Vec<Alias> = aliases.into_iter().filter(|a| a.name == name).collect();
|
||||||
|
|
||||||
if found.is_empty() {
|
if found.is_empty() {
|
||||||
println!("Aliasing {name}={value}");
|
println!("Aliasing '{name}={value}'.");
|
||||||
} else {
|
} else {
|
||||||
println!(
|
println!(
|
||||||
"Overwriting alias {name}={} with {name}={value}",
|
"Overwriting alias '{name}={}' with '{name}={value}'.",
|
||||||
found[0].value
|
found[0].value
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -43,16 +43,13 @@ impl Cmd {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn delete(&self, store: AliasStore, name: String) -> Result<()> {
|
async fn delete(&self, store: AliasStore, name: String) -> Result<()> {
|
||||||
let aliases = store.aliases().await?;
|
let mut aliases = store.aliases().await?.into_iter();
|
||||||
let found = aliases.into_iter().any(|a| a.name == name);
|
if let Some(alias) = aliases.find(|alias| alias.name == name) {
|
||||||
|
println!("Deleting '{name}={}'.", alias.value);
|
||||||
if !found {
|
|
||||||
eprintln!("Alias not found - \"{name}\" - could not delete");
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
store.delete(&name).await?;
|
store.delete(&name).await?;
|
||||||
|
} else {
|
||||||
|
eprintln!("Cannot delete '{name}': Alias not set.");
|
||||||
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user