Skip to content

Commit

Permalink
Support printing signing key public keys
Browse files Browse the repository at this point in the history
- Change `warg key id` to `warg key info`
- Print public key in addtion to key ID
  • Loading branch information
lann committed Aug 30, 2023
1 parent c082ed2 commit a5766f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ You can grant permissions to another public key with the `warg publish grant` su
warg publish grant --id example:hello ecdsa-p256:ABC...
```

> You can get your own public key with the `warg key info` subcommand.
By default, both `publish` and `yank` permissions are granted. This can be modified with the `--permission` flag.

Similarly, permissions may be revoked via `warg publish revoke`. Note that
Expand Down
16 changes: 9 additions & 7 deletions src/commands/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ impl KeyCommand {
pub async fn exec(self) -> Result<()> {
match self.command {
KeySubcommand::New(cmd) => cmd.exec().await,
KeySubcommand::Info(cmd) => cmd.exec().await,
KeySubcommand::Set(cmd) => cmd.exec().await,
KeySubcommand::Delete(cmd) => cmd.exec().await,
KeySubcommand::Id(cmd) => cmd.exec().await,
}
}
}
Expand All @@ -33,8 +33,8 @@ impl KeyCommand {
pub enum KeySubcommand {
/// Creates a new signing key for a registry in the local keyring.
New(KeyNewCommand),
/// Shows the ID of the signing key for a registry in the local keyring.
Id(KeyIdCommand),
/// Shows information about the signing key for a registry in the local keyring.
Info(KeyInfoCommand),
/// Sets the signing key for a registry in the local keyring.
Set(KeySetCommand),
/// Deletes the signing key for a registry from the local keyring.
Expand Down Expand Up @@ -118,18 +118,20 @@ impl KeyNewCommand {
}
}

/// Shows the ID of the signing key for a registry in the local keyring.
/// Shows information about the signing key for a registry in the local keyring.
#[derive(Args)]
pub struct KeyIdCommand {
pub struct KeyInfoCommand {
#[clap(flatten)]
keyring_entry: KeyringEntryArgs,
}

impl KeyIdCommand {
impl KeyInfoCommand {
/// Executes the command.
pub async fn exec(self) -> Result<()> {
let private_key = self.keyring_entry.get_key()?;
println!("{}", private_key.public_key().fingerprint());
let public_key = private_key.public_key();
println!("Key ID: {}", public_key.fingerprint());
println!("Public Key: {public_key}");
Ok(())
}
}
Expand Down

0 comments on commit a5766f9

Please sign in to comment.