#[non_exhaustive]pub enum PromptMode {
Interactive,
NonInteractive,
}Expand description
How the prompter sources answers, resolved once up front.
The decision models interactive stdio: prompts are read from stdin but
rendered to stderr, so a session is only interactive when both streams
are terminals. If stderr is redirected (cmd 2>log) the user would never
see the question, so the mode falls back to NonInteractive even when
stdin is a TTY.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Interactive
Interactive stdio (both stdin and stderr are terminals): render prompts and read live, typed answers.
NonInteractive
Non-interactive stdio (CI, piped, or a redirected prompt sink): never block; resolve each question to its declared default.
Implementations§
Source§impl PromptMode
impl PromptMode
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Resolve the mode from the current process’s stdin and stderr TTY status.
Sourcepub const fn from_stdio(stdin_is_tty: bool, stderr_is_tty: bool) -> Self
pub const fn from_stdio(stdin_is_tty: bool, stderr_is_tty: bool) -> Self
Resolve the mode from already-known stream TTY statuses (env-free, testable).
Interactive only when both the input (stdin) and the prompt sink (stderr) are terminals, so a redirected sink never leaves the user blocked behind an invisible prompt.
Sourcepub const fn is_interactive(self) -> bool
pub const fn is_interactive(self) -> bool
Whether this mode reads live answers.
Trait Implementations§
Source§impl Clone for PromptMode
impl Clone for PromptMode
Source§fn clone(&self) -> PromptMode
fn clone(&self) -> PromptMode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for PromptMode
Source§impl Debug for PromptMode
impl Debug for PromptMode
impl Eq for PromptMode
Source§impl PartialEq for PromptMode
impl PartialEq for PromptMode
impl StructuralPartialEq for PromptMode
Auto Trait Implementations§
impl Freeze for PromptMode
impl RefUnwindSafe for PromptMode
impl Send for PromptMode
impl Sync for PromptMode
impl Unpin for PromptMode
impl UnsafeUnpin for PromptMode
impl UnwindSafe for PromptMode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.