-
Notifications
You must be signed in to change notification settings - Fork 75
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
feat(commands): Add missing key subcommands #1385
base: main
Are you sure you want to change the base?
Conversation
3159172
to
7d10b92
Compare
fn inner_run(&self, repo: CliOpenRepo) -> Result<()> { | ||
repo.delete_key(&self.id)?; | ||
info!("key {} successfully removed.", self.id); | ||
Ok(()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no safe-guarding in place, e.g. a second question as in 'Key {key_id} exists, do you really want to irrecoverably delete this key? (y/N)' with defaulting to No
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No - except that repo.delete_key
won't delete the actual key used to open the repository. This ensures that always a key is left.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's good, and some safe-guarding against locking oneself out. But I think it's still important to add a normal feedback loop for deleting something. We could add a --force
delete, so that feedback loop is being jumped over.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with forget
and prune
we also don't have a feedback loop, so I would find it very irritating to have one here. forget
and prune
do have --dry-run
, but as you specify a key id to remove, I don't see much value in adding a dry-run option here..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be fair, I think it's a bit different with forget
and prune
, as you also said, and they even have a dry-run
option. I think it's just good design, to have a feedback loop when deleting something, and optionally make that circumventable. I would find it pretty weird to not have that, to be honest. The loop itself is also important to give feedback on if the key was found at all and what happens to it. I think the whole key
subcommand(s) make a pretty good role model for a tui
, actually. Where there would be probably also a feedback loop when deleting.
In general, I would find it counterproductive to let someone delete something important like a key without feedback, even if the key, that accesses the repo is not deletable.
But it can get quite annoying fast, if someone accidentally deletes keys from another device and needs to set that up again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a confirmation prompt is also as easy as:
https://docs.rs/dialoguer/0.11.0/dialoguer/struct.Confirm.html
let confirmation = Confirm::new()
.with_prompt(format!("Are you sure you want to delete key `{key}`?"))
.default(false)
.interact()?;
if confirmation {
.. delete ..
} else {
info!("Deletion aborted, nothing was deleted.")
}
depends on rustic-rs/rustic_core#383
closes #983