Skip to content

Commit

Permalink
identity: add --set-default flag to id create
Browse files Browse the repository at this point in the history
  • Loading branch information
kamirr committed Aug 8, 2024
1 parent a42c71d commit 2b6daee
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/identity/src/cli/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ pub enum IdentityCommand {
/// password for keystore
#[structopt(long = "no-password")]
no_password: bool,

/// Set the newly created identity as the default, requires deamon restart
#[structopt(long = "set-default")]
set_default: bool,
},
/// Update given identity
Update {
Expand All @@ -151,6 +155,8 @@ pub enum IdentityCommand {
alias_or_id: NodeOrAlias,
#[structopt(long)]
alias: Option<String>,

/// Set the identity as the default, requires deamon restart
#[structopt(long = "set-default")]
set_default: bool,
},
Expand Down Expand Up @@ -314,6 +320,7 @@ impl IdentityCommand {
from_private_key,
password,
no_password,
set_default,
} => {
if from_keystore.is_some() && from_private_key.is_some() {
anyhow::bail!("Only one of --from-keystore or --from-private-key can be used")
Expand Down Expand Up @@ -364,7 +371,13 @@ impl IdentityCommand {
from_keystore: Some(key_file),
})
.await
.map_err(anyhow::Error::msg)??;

let id = bus::service(identity::BUS_ID)
.send(identity::Update::with_id(id.node_id).with_default(*set_default))
.await
.map_err(anyhow::Error::msg)?;

CommandOutput::object(id)
}
IdentityCommand::Lock {
Expand Down

0 comments on commit 2b6daee

Please sign in to comment.