Don't run Powershell in a dumb terminal (fix #110)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use crate::executor::{CommandExt, RunType};
|
use crate::executor::{CommandExt, RunType};
|
||||||
use crate::terminal::print_separator;
|
use crate::terminal::{is_dumb, print_separator};
|
||||||
use crate::utils::{self, which};
|
use crate::utils::{self, which};
|
||||||
use log::error;
|
use log::error;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
@@ -46,9 +46,13 @@ pub struct Powershell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Powershell {
|
impl Powershell {
|
||||||
|
/// Returns a powershell instance.
|
||||||
|
///
|
||||||
|
/// If the powershell binary is not found, or the current terminal is dumb
|
||||||
|
/// then the instance of this struct will skip all the powershell steps.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Powershell {
|
Powershell {
|
||||||
path: which("powershell"),
|
path: which("powershell").filter(|_| !is_dumb()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -126,3 +126,8 @@ pub fn print_warning<P: AsRef<str>>(message: P) {
|
|||||||
pub fn print_result<P: AsRef<str>>(key: P, succeeded: bool) {
|
pub fn print_result<P: AsRef<str>>(key: P, succeeded: bool) {
|
||||||
TERMINAL.lock().unwrap().print_result(key, succeeded)
|
TERMINAL.lock().unwrap().print_result(key, succeeded)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Tells whether the terminal is dumb.
|
||||||
|
pub fn is_dumb() -> bool {
|
||||||
|
TERMINAL.lock().unwrap().width.is_none()
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user