Skip to content

Commit

Permalink
feat: print confirmation of identify command completion (#1013)
Browse files Browse the repository at this point in the history
Print what was done, in the past tense, if `identity new`, `identity remove`, `identity rename`, or creation of the default identity were successful.
  • Loading branch information
ericswanson-dfinity authored Sep 11, 2020
1 parent 3e57db7 commit c7ec140
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
7 changes: 7 additions & 0 deletions e2e/bats/identity_command.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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" {
Expand Down
5 changes: 4 additions & 1 deletion src/dfx/src/commands/identity/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
5 changes: 4 additions & 1 deletion src/dfx/src/commands/identity/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
1 change: 1 addition & 0 deletions src/dfx/src/commands/identity/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions src/dfx/src/lib/identity/identity_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit c7ec140

Please sign in to comment.