Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/prompts/confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ impl Confirm<'_> {
}

fn _interact_on(self, term: &Term, allow_quit: bool) -> Result<Option<bool>> {
if !term.is_term() {
return Err(io::Error::new(io::ErrorKind::NotConnected, "not a terminal").into());
}

let mut render = TermThemeRenderer::new(term, self.theme);

let default_if_show = if self.show_default {
Expand Down
10 changes: 9 additions & 1 deletion src/prompts/input.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{cmp::Ordering, fmt::Debug, iter, str::FromStr};
use std::{cmp::Ordering, fmt::Debug, io, iter, str::FromStr};

use console::{Key, Term};

Expand Down Expand Up @@ -288,6 +288,10 @@ where

/// Like [`interact_text`](Self::interact_text) but allows a specific terminal to be set.
pub fn interact_text_on(mut self, term: &Term) -> Result<T> {
if !term.is_term() {
return Err(io::Error::new(io::ErrorKind::NotConnected, "not a terminal").into());
}

let mut render = TermThemeRenderer::new(term, self.theme);

loop {
Expand Down Expand Up @@ -639,6 +643,10 @@ where

/// Like [`interact`](Self::interact) but allows a specific terminal to be set.
pub fn interact_on(mut self, term: &Term) -> Result<T> {
if !term.is_term() {
return Err(io::Error::new(io::ErrorKind::NotConnected, "not a terminal").into());
}

let mut render = TermThemeRenderer::new(term, self.theme);

loop {
Expand Down
4 changes: 4 additions & 0 deletions src/prompts/multi_select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ impl MultiSelect<'_> {
}

fn _interact_on(self, term: &Term, allow_quit: bool) -> Result<Option<Vec<usize>>> {
if !term.is_term() {
return Err(io::Error::new(io::ErrorKind::NotConnected, "not a terminal").into());
}

if self.items.is_empty() {
return Err(io::Error::new(
io::ErrorKind::Other,
Expand Down
6 changes: 6 additions & 0 deletions src/prompts/password.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::io;

use console::Term;
use zeroize::Zeroizing;

Expand Down Expand Up @@ -135,6 +137,10 @@ impl<'a> Password<'a> {

/// Like [`interact`](Self::interact) but allows a specific terminal to be set.
pub fn interact_on(self, term: &Term) -> Result<String> {
if !term.is_term() {
return Err(io::Error::new(io::ErrorKind::NotConnected, "not a terminal").into());
}

let mut render = TermThemeRenderer::new(term, self.theme);
render.set_prompts_reset_height(false);

Expand Down
4 changes: 4 additions & 0 deletions src/prompts/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ impl Select<'_> {

/// Like `interact` but allows a specific terminal to be set.
fn _interact_on(self, term: &Term, allow_quit: bool) -> Result<Option<usize>> {
if !term.is_term() {
return Err(io::Error::new(io::ErrorKind::NotConnected, "not a terminal").into());
}

if self.items.is_empty() {
return Err(io::Error::new(
io::ErrorKind::Other,
Expand Down
4 changes: 4 additions & 0 deletions src/prompts/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ impl Sort<'_> {
}

fn _interact_on(self, term: &Term, allow_quit: bool) -> Result<Option<Vec<usize>>> {
if !term.is_term() {
return Err(io::Error::new(io::ErrorKind::NotConnected, "not a terminal").into());
}

if self.items.is_empty() {
return Err(io::Error::new(
io::ErrorKind::Other,
Expand Down