From c7ec140d77c03b30355b990290b4bbd39beaa202 Mon Sep 17 00:00:00 2001 From: Eric Swanson <64809312+ericswanson-dfinity@users.noreply.github.com> Date: Fri, 11 Sep 2020 12:42:08 -0700 Subject: [PATCH] feat: print confirmation of identify command completion (#1013) Print what was done, in the past tense, if `identity new`, `identity remove`, `identity rename`, or creation of the default identity were successful. --- e2e/bats/identity_command.bash | 7 +++++++ src/dfx/src/commands/identity/new.rs | 5 ++++- src/dfx/src/commands/identity/remove.rs | 5 ++++- src/dfx/src/commands/identity/rename.rs | 1 + src/dfx/src/lib/identity/identity_manager.rs | 1 + 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/e2e/bats/identity_command.bash b/e2e/bats/identity_command.bash index a6d56692a8..7a1caafa32 100644 --- a/e2e/bats/identity_command.bash +++ b/e2e/bats/identity_command.bash @@ -46,6 +46,8 @@ teardown() { @test "identity new: creates a new identity" { assert_command dfx identity new alice + assert_match 'Creating identity: "alice".' "$stderr" + assert_match 'Created identity: "alice".' "$stderr" assert_command head $HOME/.config/dfx/identity/alice/identity.pem assert_match "BEGIN PRIVATE KEY" @@ -78,6 +80,8 @@ teardown() { assert_match 'alice default' assert_command dfx identity remove alice + assert_match 'Removing identity "alice".' "$stderr" + assert_match 'Removed identity "alice".' "$stderr" assert_command_fail cat $HOME/.config/dfx/identity/alice/identity.pem assert_command dfx identity list @@ -124,6 +128,8 @@ teardown() { local key=$(cat $HOME/.config/dfx/identity/alice/identity.pem) assert_command dfx identity rename alice bob + assert_match 'Renaming identity "alice" to "bob".' "$stderr" + assert_match 'Renamed identity "alice" to "bob".' "$stderr" assert_command dfx identity list assert_match 'bob default' @@ -209,6 +215,7 @@ teardown() { assert_command dfx identity whoami assert_eq 'default' "$stdout" assert_match 'Creating the "default" identity.' "$stderr" + assert_match 'Created the "default" identity.' "$stderr" } @test "identity whoami: shows the current identity" { diff --git a/src/dfx/src/commands/identity/new.rs b/src/dfx/src/commands/identity/new.rs index 90fe4bc0b7..e76225d15b 100644 --- a/src/dfx/src/commands/identity/new.rs +++ b/src/dfx/src/commands/identity/new.rs @@ -22,5 +22,8 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let log = env.get_logger(); info!(log, r#"Creating identity: "{}"."#, name); - IdentityManager::new(env)?.create_new_identity(name) + IdentityManager::new(env)?.create_new_identity(name)?; + + info!(log, r#"Created identity: "{}"."#, name); + Ok(()) } diff --git a/src/dfx/src/commands/identity/remove.rs b/src/dfx/src/commands/identity/remove.rs index d9e324feb3..e6856c287e 100644 --- a/src/dfx/src/commands/identity/remove.rs +++ b/src/dfx/src/commands/identity/remove.rs @@ -22,5 +22,8 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let log = env.get_logger(); info!(log, r#"Removing identity "{}"."#, name); - IdentityManager::new(env)?.remove(name) + IdentityManager::new(env)?.remove(name)?; + + info!(log, r#"Removed identity "{}"."#, name); + Ok(()) } diff --git a/src/dfx/src/commands/identity/rename.rs b/src/dfx/src/commands/identity/rename.rs index 39054bea44..23d6638fbc 100644 --- a/src/dfx/src/commands/identity/rename.rs +++ b/src/dfx/src/commands/identity/rename.rs @@ -31,6 +31,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult { let renamed_default = IdentityManager::new(env)?.rename(from, to)?; + info!(log, r#"Renamed identity "{}" to "{}"."#, from, to); if renamed_default { info!(log, r#"Now using identity: "{}"."#, to); } diff --git a/src/dfx/src/lib/identity/identity_manager.rs b/src/dfx/src/lib/identity/identity_manager.rs index 666c37fbe6..bf7710a628 100644 --- a/src/dfx/src/lib/identity/identity_manager.rs +++ b/src/dfx/src/lib/identity/identity_manager.rs @@ -262,6 +262,7 @@ fn initialize( default: String::from(DEFAULT_IDENTITY_NAME), }; write_configuration(&identity_json_path, &config)?; + slog::info!(logger, r#"Created the "default" identity."#); Ok(config) }