mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-07 12:05:46 +00:00
feat: use ChoicePrompt in user_wants_to_continue method
This commit is contained in:
parent
98ca77f953
commit
8a8e44abe7
@ -78,18 +78,25 @@ pub fn user_wants_to_continue(
|
|||||||
QuestionPolicy::AlwaysYes => Ok(true),
|
QuestionPolicy::AlwaysYes => Ok(true),
|
||||||
QuestionPolicy::AlwaysNo => Ok(false),
|
QuestionPolicy::AlwaysNo => Ok(false),
|
||||||
QuestionPolicy::Ask => {
|
QuestionPolicy::Ask => {
|
||||||
|
let path = path_to_str(strip_cur_dir(path));
|
||||||
let action = match question_action {
|
let action = match question_action {
|
||||||
QuestionAction::Compression => "compress",
|
QuestionAction::Compression => "compress",
|
||||||
QuestionAction::Decompression => "decompress",
|
QuestionAction::Decompression => "decompress",
|
||||||
};
|
};
|
||||||
let path = path_to_str(strip_cur_dir(path));
|
|
||||||
let path = Some(&*path);
|
ChoicePrompt::new(
|
||||||
let placeholder = Some("FILE");
|
format!("Do you want to {action} {path}?"),
|
||||||
Confirmation::new(&format!("Do you want to {action} 'FILE'?"), placeholder).ask(path)
|
[
|
||||||
|
("yes", true, *colors::GREEN),
|
||||||
|
("no", false, *colors::RED),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.ask()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Choise dialog for end user with [option1/option2/...] question.
|
/// Choise dialog for end user with [option1/option2/...] question.
|
||||||
///
|
///
|
||||||
/// If the placeholder is found in the prompt text, it will be replaced to form the final message.
|
/// If the placeholder is found in the prompt text, it will be replaced to form the final message.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user