Skip to content

Commit

Permalink
fix(rust): enroll command won't wait for user input if --no-input
Browse files Browse the repository at this point in the history
… is passed
  • Loading branch information
adrianbenavides authored and metaclips committed Jun 11, 2024
1 parent 2ddcccf commit a29c36c
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions implementations/rust/ockam/ockam_command/src/enroll/oidc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,34 @@ impl OidcServiceExt for OidcService {
)
},
);
opts.terminal.write_line(&otc_string)?.write(fmt_log!(
"Press {} to open {} in your browser.\n",
" ENTER ↵ ".bg_white().black().blink(),
color_uri(&device_code.verification_uri)
))?;

let mut input = String::new();
match stdin().read_line(&mut input) {
Ok(_) => {
opts.terminal.write_line(&fmt_log!(
"Opening {}, in your browser, to begin activating this machine...\n",
color_uri(&device_code.verification_uri)
))?;
}
Err(_e) => {
return Err(miette!(
"Couldn't read user input or enter keypress from stdin"
))?;
opts.terminal.write_line(&otc_string)?;

if opts.terminal.can_ask_for_user_input() {
opts.terminal.write(fmt_log!(
"Press {} to open {} in your browser.\n",
" ENTER ↵ ".bg_white().black().blink(),
color_uri(&device_code.verification_uri)
))?;

let mut input = String::new();
match stdin().read_line(&mut input) {
Ok(_) => {
opts.terminal.write_line(&fmt_log!(
"Opening {}, in your browser, to begin activating this machine...\n",
color_uri(&device_code.verification_uri)
))?;
}
Err(_e) => {
return Err(miette!(
"Couldn't read user input or enter keypress from stdin"
))?;
}
}
} else {
opts.terminal.write_line(&fmt_log!(
"Open {} in your browser to begin activating this machine.\n",
color_uri(&device_code.verification_uri)
))?;
}
}

Expand Down

0 comments on commit a29c36c

Please sign in to comment.