File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ pub struct Confirm<'a> {
3535 show_default : bool ,
3636 wait_for_newline : bool ,
3737 theme : & ' a dyn Theme ,
38+ show_hint : bool ,
3839}
3940
4041impl Default for Confirm < ' static > {
@@ -97,6 +98,14 @@ impl Confirm<'_> {
9798 self
9899 }
99100
101+ /// Disables or enables the hint display (e.g. `[y/n]`).
102+ ///
103+ /// The default is to show the hint.
104+ pub fn show_hint ( mut self , val : bool ) -> Self {
105+ self . show_hint = val;
106+ self
107+ }
108+
100109 /// Enables user interaction and returns the result.
101110 ///
102111 /// The dialog is rendered on stderr.
@@ -163,7 +172,12 @@ impl Confirm<'_> {
163172 None
164173 } ;
165174
166- render. confirm_prompt ( & self . prompt , default_if_show) ?;
175+ term. clear_line ( ) ?;
176+ if self . show_hint {
177+ render. confirm_prompt ( & self . prompt , default_if_show) ?;
178+ } else {
179+ term. write_str ( & format ! ( "{} " , & self . prompt) ) ?;
180+ }
167181
168182 term. hide_cursor ( ) ?;
169183 term. flush ( ) ?;
@@ -260,6 +274,7 @@ impl<'a> Confirm<'a> {
260274 show_default : true ,
261275 wait_for_newline : false ,
262276 theme,
277+ show_hint : true ,
263278 }
264279 }
265280}
Original file line number Diff line number Diff line change @@ -172,7 +172,6 @@ impl Theme for ColorfulTheme {
172172 ) ,
173173 }
174174 }
175-
176175 /// Formats a confirm prompt after selection.
177176 fn format_confirm_prompt_selection (
178177 & self ,
You can’t perform that action at this time.
0 commit comments