Skip to content

Commit 8a5f5e2

Browse files
committed
reinstall: Use indoc to format prompts
Signed-off-by: ckyrouac <[email protected]>
1 parent d1b3ea1 commit 8a5f5e2

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

system-reinstall-bootc/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ anyhow = { workspace = true }
1919
bootc-utils = { path = "../utils" }
2020
clap = { workspace = true, features = ["derive"] }
2121
dialoguer = "0.11.0"
22+
indoc = { workspace = true }
2223
log = "0.4.21"
2324
openssh-keys = "0.6.4"
2425
rustix = { workspace = true }

system-reinstall-bootc/src/prompt.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ const NO_SSH_PROMPT: &str = "None of the users on this system found have authori
66
you may not be able to log in after reinstalling. Do you want to continue?";
77

88
fn prompt_single_user(user: &crate::users::UserKeys) -> Result<Vec<&crate::users::UserKeys>> {
9-
let prompt = format!(
10-
"Found only one user ({}) with {} SSH authorized keys.\n\
11-
Would you like to import its SSH authorized keys\n\
12-
into the root user on the new bootc system?",
13-
user.user,
14-
user.num_keys(),
15-
);
9+
let prompt = indoc::formatdoc! {
10+
"Found only one user ({user}) with {num_keys} SSH authorized keys.
11+
Would you like to import its SSH authorized keys
12+
into the root user on the new bootc system?",
13+
user = user.user,
14+
num_keys = user.num_keys(),
15+
};
1616
let answer = ask_yes_no(&prompt, true)?;
1717
Ok(if answer { vec![&user] } else { vec![] })
1818
}
@@ -24,10 +24,10 @@ fn prompt_user_selection(
2424

2525
// TODO: Handle https://github.com/console-rs/dialoguer/issues/77
2626
let selected_user_indices: Vec<usize> = dialoguer::MultiSelect::new()
27-
.with_prompt(
28-
"Select which user's SSH authorized keys you want to\n\
27+
.with_prompt(indoc::indoc! {
28+
"Select which user's SSH authorized keys you want to
2929
import into the root user of the new bootc system",
30-
)
30+
})
3131
.items(&keys)
3232
.interact()?;
3333

0 commit comments

Comments
 (0)