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

feat(commands): Add missing key subcommands #1385

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

aawsome
Copy link
Member

@aawsome aawsome commented Dec 10, 2024

depends on rustic-rs/rustic_core#383

closes #983

@aawsome aawsome added the S-blocked Status: Blocked from merging/working on due to some issue label Dec 10, 2024
Comment on lines +178 to +182
fn inner_run(&self, repo: CliOpenRepo) -> Result<()> {
repo.delete_key(&self.id)?;
info!("key {} successfully removed.", self.id);
Ok(())
}
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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..

Copy link
Contributor

@simonsan simonsan Dec 10, 2024

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.

Copy link
Contributor

@simonsan simonsan Dec 10, 2024

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.")
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-blocked Status: Blocked from merging/working on due to some issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

key: better key handling and additional sub commands
2 participants