As pointed out in #736, it is possible to rename an identity to another existing identity. To remedy this the existing name is now passed in as an Option<&String>
and checked against user input
YJXRCXOSO2J5BFFR6QKFDVV3RJ5J3QXB4UZ3DVQZLYTF5RJ4TNJAC
if replace_current {
// The user is trying to edit an existing identity
Ok(())
if let Some(name) = replace_current {
if name == input {
// The user is trying to edit an existing identity
Ok(())
} else {
// The user is editing an existing identity but trying to overwrite a different name
Err(format!("The identity {existing_identity} already exists. Either remove the identity or edit it directly."))
}
Err(format!("That identity already exists: {existing_identity}",))
// The user is creating a new identity but trying to use an existing name
Err(format!("The identity {existing_identity} already exists. Either remove the identity or edit it directly."))