-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow users to get the principal id of the current identity (#1046
) * init * add message file * fmt and comma * a few tests * rename * rename in tests Co-authored-by: Prithvi Shahi <prithvi@dfinity.org>
- Loading branch information
Showing
5 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use crate::lib::environment::Environment; | ||
use crate::lib::error::DfxResult; | ||
use crate::lib::identity::identity_manager::IdentityManager; | ||
use crate::lib::message::UserMessage; | ||
use clap::{App, ArgMatches, SubCommand}; | ||
|
||
pub fn construct() -> App<'static, 'static> { | ||
SubCommand::with_name("get-principal").about(UserMessage::GetPrincipalId.to_str()) | ||
} | ||
|
||
pub fn exec(env: &dyn Environment, _args: &ArgMatches<'_>) -> DfxResult { | ||
let identity = IdentityManager::new(env)?.instantiate_selected_identity()?; | ||
let principal_id = identity.sender()?; | ||
println!("{}", principal_id.to_text()); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters