mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-12-26 03:27:30 +00:00
refactor: replace ansi_term
with nu_ansi_term
(#4339)
This commit is contained in:
parent
020759e56a
commit
6ac5df904b
@ -180,7 +180,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
27
Cargo.lock
generated
27
Cargo.lock
generated
@ -37,15 +37,6 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ansi_term"
|
|
||||||
version = "0.12.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
|
|
||||||
dependencies = [
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.62"
|
version = "1.0.62"
|
||||||
@ -1757,6 +1748,16 @@ dependencies = [
|
|||||||
"zvariant_derive",
|
"zvariant_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nu-ansi-term"
|
||||||
|
version = "0.46.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
|
||||||
|
dependencies = [
|
||||||
|
"overload",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-derive"
|
name = "num-derive"
|
||||||
version = "0.3.3"
|
version = "0.3.3"
|
||||||
@ -1903,6 +1904,12 @@ version = "6.3.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff"
|
checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "overload"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parking"
|
name = "parking"
|
||||||
version = "2.0.0"
|
version = "2.0.0"
|
||||||
@ -2661,7 +2668,6 @@ dependencies = [
|
|||||||
name = "starship"
|
name = "starship"
|
||||||
version = "1.10.2"
|
version = "1.10.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi_term",
|
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"clap_complete",
|
"clap_complete",
|
||||||
@ -2679,6 +2685,7 @@ dependencies = [
|
|||||||
"mockall",
|
"mockall",
|
||||||
"nix 0.25.0",
|
"nix 0.25.0",
|
||||||
"notify-rust",
|
"notify-rust",
|
||||||
|
"nu-ansi-term",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"open",
|
"open",
|
||||||
"os_info",
|
"os_info",
|
||||||
|
@ -35,7 +35,6 @@ config-schema = ["schemars"]
|
|||||||
notify = ["notify-rust"]
|
notify = ["notify-rust"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ansi_term = "0.12.1"
|
|
||||||
chrono = { version = "0.4.22", features = ["clock", "std"] }
|
chrono = { version = "0.4.22", features = ["clock", "std"] }
|
||||||
clap = { version = "=3.2.20", features = ["derive", "cargo", "unicode", "unstable-v4"] }
|
clap = { version = "=3.2.20", features = ["derive", "cargo", "unicode", "unstable-v4"] }
|
||||||
clap_complete = "3.2.4"
|
clap_complete = "3.2.4"
|
||||||
@ -51,6 +50,7 @@ log = { version = "0.4.16", features = ["std"] }
|
|||||||
# nofity-rust is optional (on by default) because the crate doesn't currently build for darwin with nix
|
# nofity-rust is optional (on by default) because the crate doesn't currently build for darwin with nix
|
||||||
# see: https://github.com/NixOS/nixpkgs/issues/160876
|
# see: https://github.com/NixOS/nixpkgs/issues/160876
|
||||||
notify-rust = { version = "4.5.8", optional = true }
|
notify-rust = { version = "4.5.8", optional = true }
|
||||||
|
nu-ansi-term = "0.46.0"
|
||||||
once_cell = "1.13.1"
|
once_cell = "1.13.1"
|
||||||
open = "3.0.2"
|
open = "3.0.2"
|
||||||
os_info = "3.5.0"
|
os_info = "3.5.0"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::serde_utils::ValueDeserializer;
|
use crate::serde_utils::ValueDeserializer;
|
||||||
use crate::utils;
|
use crate::utils;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use serde::{
|
use serde::{
|
||||||
de::value::Error as ValueError, de::Error as SerdeError, Deserialize, Deserializer, Serialize,
|
de::value::Error as ValueError, de::Error as SerdeError, Deserialize, Deserializer, Serialize,
|
||||||
};
|
};
|
||||||
@ -251,7 +251,7 @@ impl StarshipConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Deserialize a style string in the starship format with serde
|
/// Deserialize a style string in the starship format with serde
|
||||||
pub fn deserialize_style<'de, D>(de: D) -> Result<ansi_term::Style, D::Error>
|
pub fn deserialize_style<'de, D>(de: D) -> Result<nu_ansi_term::Style, D::Error>
|
||||||
where
|
where
|
||||||
D: Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
{
|
{
|
||||||
@ -271,10 +271,10 @@ where
|
|||||||
- 'blink'
|
- 'blink'
|
||||||
- '<color>' (see the `parse_color_string` doc for valid color strings)
|
- '<color>' (see the `parse_color_string` doc for valid color strings)
|
||||||
*/
|
*/
|
||||||
pub fn parse_style_string(style_string: &str) -> Option<ansi_term::Style> {
|
pub fn parse_style_string(style_string: &str) -> Option<nu_ansi_term::Style> {
|
||||||
style_string
|
style_string
|
||||||
.split_whitespace()
|
.split_whitespace()
|
||||||
.fold(Some(ansi_term::Style::new()), |maybe_style, token| {
|
.fold(Some(nu_ansi_term::Style::new()), |maybe_style, token| {
|
||||||
maybe_style.and_then(|style| {
|
maybe_style.and_then(|style| {
|
||||||
let token = token.to_lowercase();
|
let token = token.to_lowercase();
|
||||||
|
|
||||||
@ -333,7 +333,7 @@ pub fn parse_style_string(style_string: &str) -> Option<ansi_term::Style> {
|
|||||||
- u8 (a number from 0-255, representing an ANSI color)
|
- u8 (a number from 0-255, representing an ANSI color)
|
||||||
- colstring (one of the 16 predefined color strings)
|
- colstring (one of the 16 predefined color strings)
|
||||||
*/
|
*/
|
||||||
fn parse_color_string(color_string: &str) -> Option<ansi_term::Color> {
|
fn parse_color_string(color_string: &str) -> Option<nu_ansi_term::Color> {
|
||||||
// Parse RGB hex values
|
// Parse RGB hex values
|
||||||
log::trace!("Parsing color_string: {}", color_string);
|
log::trace!("Parsing color_string: {}", color_string);
|
||||||
if color_string.starts_with('#') {
|
if color_string.starts_with('#') {
|
||||||
@ -349,7 +349,7 @@ fn parse_color_string(color_string: &str) -> Option<ansi_term::Color> {
|
|||||||
let g: u8 = u8::from_str_radix(&color_string[3..5], 16).ok()?;
|
let g: u8 = u8::from_str_radix(&color_string[3..5], 16).ok()?;
|
||||||
let b: u8 = u8::from_str_radix(&color_string[5..7], 16).ok()?;
|
let b: u8 = u8::from_str_radix(&color_string[5..7], 16).ok()?;
|
||||||
log::trace!("Read RGB color string: {},{},{}", r, g, b);
|
log::trace!("Read RGB color string: {},{},{}", r, g, b);
|
||||||
return Some(Color::RGB(r, g, b));
|
return Some(Color::Rgb(r, g, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse a u8 (ansi color)
|
// Parse a u8 (ansi color)
|
||||||
@ -369,14 +369,14 @@ fn parse_color_string(color_string: &str) -> Option<ansi_term::Color> {
|
|||||||
"purple" => Some(Color::Purple),
|
"purple" => Some(Color::Purple),
|
||||||
"cyan" => Some(Color::Cyan),
|
"cyan" => Some(Color::Cyan),
|
||||||
"white" => Some(Color::White),
|
"white" => Some(Color::White),
|
||||||
"bright-black" => Some(Color::Fixed(8)), // "bright-black" is dark grey
|
"bright-black" => Some(Color::DarkGray), // "bright-black" is dark grey
|
||||||
"bright-red" => Some(Color::Fixed(9)),
|
"bright-red" => Some(Color::LightRed),
|
||||||
"bright-green" => Some(Color::Fixed(10)),
|
"bright-green" => Some(Color::LightGreen),
|
||||||
"bright-yellow" => Some(Color::Fixed(11)),
|
"bright-yellow" => Some(Color::LightYellow),
|
||||||
"bright-blue" => Some(Color::Fixed(12)),
|
"bright-blue" => Some(Color::LightBlue),
|
||||||
"bright-purple" => Some(Color::Fixed(13)),
|
"bright-purple" => Some(Color::LightPurple),
|
||||||
"bright-cyan" => Some(Color::Fixed(14)),
|
"bright-cyan" => Some(Color::LightCyan),
|
||||||
"bright-white" => Some(Color::Fixed(15)),
|
"bright-white" => Some(Color::LightGray),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -391,7 +391,7 @@ fn parse_color_string(color_string: &str) -> Option<ansi_term::Color> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use ansi_term::Style;
|
use nu_ansi_term::Style;
|
||||||
|
|
||||||
// Small wrapper to allow deserializing Style without a struct with #[serde(deserialize_with=)]
|
// Small wrapper to allow deserializing Style without a struct with #[serde(deserialize_with=)]
|
||||||
#[derive(Default, Clone, Debug, PartialEq)]
|
#[derive(Default, Clone, Debug, PartialEq)]
|
||||||
@ -574,7 +574,7 @@ mod tests {
|
|||||||
let config = Value::from("#a12BcD");
|
let config = Value::from("#a12BcD");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<StyleWrapper>::from_config(&config).unwrap().0,
|
<StyleWrapper>::from_config(&config).unwrap().0,
|
||||||
Color::RGB(0xA1, 0x2B, 0xCD).into()
|
Color::Rgb(0xA1, 0x2B, 0xCD).into()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -600,7 +600,7 @@ mod tests {
|
|||||||
assert!(mystyle.is_dimmed);
|
assert!(mystyle.is_dimmed);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
mystyle,
|
mystyle,
|
||||||
ansi_term::Style::new()
|
nu_ansi_term::Style::new()
|
||||||
.bold()
|
.bold()
|
||||||
.italic()
|
.italic()
|
||||||
.underline()
|
.underline()
|
||||||
@ -620,7 +620,7 @@ mod tests {
|
|||||||
assert!(mystyle.is_reverse);
|
assert!(mystyle.is_reverse);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
mystyle,
|
mystyle,
|
||||||
ansi_term::Style::new()
|
nu_ansi_term::Style::new()
|
||||||
.bold()
|
.bold()
|
||||||
.italic()
|
.italic()
|
||||||
.underline()
|
.underline()
|
||||||
@ -641,7 +641,7 @@ mod tests {
|
|||||||
assert!(mystyle.is_blink);
|
assert!(mystyle.is_blink);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
mystyle,
|
mystyle,
|
||||||
ansi_term::Style::new()
|
nu_ansi_term::Style::new()
|
||||||
.bold()
|
.bold()
|
||||||
.italic()
|
.italic()
|
||||||
.underline()
|
.underline()
|
||||||
@ -662,7 +662,7 @@ mod tests {
|
|||||||
assert!(mystyle.is_hidden);
|
assert!(mystyle.is_hidden);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
mystyle,
|
mystyle,
|
||||||
ansi_term::Style::new()
|
nu_ansi_term::Style::new()
|
||||||
.bold()
|
.bold()
|
||||||
.italic()
|
.italic()
|
||||||
.underline()
|
.underline()
|
||||||
@ -683,7 +683,7 @@ mod tests {
|
|||||||
assert!(mystyle.is_strikethrough);
|
assert!(mystyle.is_strikethrough);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
mystyle,
|
mystyle,
|
||||||
ansi_term::Style::new()
|
nu_ansi_term::Style::new()
|
||||||
.bold()
|
.bold()
|
||||||
.italic()
|
.italic()
|
||||||
.underline()
|
.underline()
|
||||||
@ -698,7 +698,7 @@ mod tests {
|
|||||||
// Test a "plain" style with no formatting
|
// Test a "plain" style with no formatting
|
||||||
let config = Value::from("");
|
let config = Value::from("");
|
||||||
let plain_style = <StyleWrapper>::from_config(&config).unwrap().0;
|
let plain_style = <StyleWrapper>::from_config(&config).unwrap().0;
|
||||||
assert_eq!(plain_style, ansi_term::Style::new());
|
assert_eq!(plain_style, nu_ansi_term::Style::new());
|
||||||
|
|
||||||
// Test a string that's clearly broken
|
// Test a string that's clearly broken
|
||||||
let config = Value::from("djklgfhjkldhlhk;j");
|
let config = Value::from("djklgfhjkldhlhk;j");
|
||||||
@ -763,7 +763,7 @@ mod tests {
|
|||||||
Style::new()
|
Style::new()
|
||||||
.underline()
|
.underline()
|
||||||
.fg(Color::Fixed(120))
|
.fg(Color::Fixed(120))
|
||||||
.on(Color::RGB(5, 5, 5))
|
.on(Color::Rgb(5, 5, 5))
|
||||||
);
|
);
|
||||||
|
|
||||||
// Test that the last color style is always the one used
|
// Test that the last color style is always the one used
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use ansi_term::Style;
|
use nu_ansi_term::Style;
|
||||||
use pest::error::Error as PestError;
|
use pest::error::Error as PestError;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
@ -465,7 +465,7 @@ where
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
|
|
||||||
// match_next(result: IterMut<Segment>, value, style)
|
// match_next(result: IterMut<Segment>, value, style)
|
||||||
macro_rules! match_next {
|
macro_rules! match_next {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::utils;
|
use crate::utils;
|
||||||
use ansi_term::Color;
|
|
||||||
use log::{Level, LevelFilter, Metadata, Record};
|
use log::{Level, LevelFilter, Metadata, Record};
|
||||||
|
use nu_ansi_term::Color;
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashSet,
|
collections::HashSet,
|
||||||
|
@ -114,7 +114,7 @@ enum Commands {
|
|||||||
fn main() {
|
fn main() {
|
||||||
// Configure the current terminal on windows to support ANSI escape sequences.
|
// Configure the current terminal on windows to support ANSI escape sequences.
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
let _ = ansi_term::enable_ansi_support();
|
let _ = nu_ansi_term::enable_ansi_support();
|
||||||
logger::init();
|
logger::init();
|
||||||
init_global_threadpool();
|
init_global_threadpool();
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ use crate::context::Shell;
|
|||||||
use crate::segment;
|
use crate::segment;
|
||||||
use crate::segment::{FillSegment, Segment};
|
use crate::segment::{FillSegment, Segment};
|
||||||
use crate::utils::wrap_colorseq_for_shell;
|
use crate::utils::wrap_colorseq_for_shell;
|
||||||
use ansi_term::{ANSIString, ANSIStrings};
|
use nu_ansi_term::{AnsiString, AnsiStrings};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
@ -146,15 +146,15 @@ impl<'a> Module<'a> {
|
|||||||
self.segments.iter().map(segment::Segment::value).collect()
|
self.segments.iter().map(segment::Segment::value).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a vector of colored `ANSIString` elements to be later used with
|
/// Returns a vector of colored `AnsiString` elements to be later used with
|
||||||
/// `ANSIStrings()` to optimize ANSI codes
|
/// `AnsiStrings()` to optimize ANSI codes
|
||||||
pub fn ansi_strings(&self) -> Vec<ANSIString> {
|
pub fn ansi_strings(&self) -> Vec<AnsiString> {
|
||||||
self.ansi_strings_for_shell(Shell::Unknown, None)
|
self.ansi_strings_for_shell(Shell::Unknown, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ansi_strings_for_shell(&self, shell: Shell, width: Option<usize>) -> Vec<ANSIString> {
|
pub fn ansi_strings_for_shell(&self, shell: Shell, width: Option<usize>) -> Vec<AnsiString> {
|
||||||
let mut iter = self.segments.iter().peekable();
|
let mut iter = self.segments.iter().peekable();
|
||||||
let mut ansi_strings: Vec<ANSIString> = Vec::new();
|
let mut ansi_strings: Vec<AnsiString> = Vec::new();
|
||||||
while iter.peek().is_some() {
|
while iter.peek().is_some() {
|
||||||
ansi_strings.extend(ansi_line(&mut iter, width));
|
ansi_strings.extend(ansi_line(&mut iter, width));
|
||||||
}
|
}
|
||||||
@ -171,27 +171,27 @@ impl<'a> Module<'a> {
|
|||||||
impl<'a> fmt::Display for Module<'a> {
|
impl<'a> fmt::Display for Module<'a> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let ansi_strings = self.ansi_strings();
|
let ansi_strings = self.ansi_strings();
|
||||||
write!(f, "{}", ANSIStrings(&ansi_strings))
|
write!(f, "{}", AnsiStrings(&ansi_strings))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ansi_strings_modified(ansi_strings: Vec<ANSIString>, shell: Shell) -> Vec<ANSIString> {
|
fn ansi_strings_modified(ansi_strings: Vec<AnsiString>, shell: Shell) -> Vec<AnsiString> {
|
||||||
ansi_strings
|
ansi_strings
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|ansi| {
|
.map(|ansi| {
|
||||||
let wrapped = wrap_colorseq_for_shell(ansi.to_string(), shell);
|
let wrapped = wrap_colorseq_for_shell(ansi.to_string(), shell);
|
||||||
ANSIString::from(wrapped)
|
AnsiString::from(wrapped)
|
||||||
})
|
})
|
||||||
.collect::<Vec<ANSIString>>()
|
.collect::<Vec<AnsiString>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ansi_line<'a, I>(segments: &mut I, term_width: Option<usize>) -> Vec<ANSIString<'a>>
|
fn ansi_line<'a, I>(segments: &mut I, term_width: Option<usize>) -> Vec<AnsiString<'a>>
|
||||||
where
|
where
|
||||||
I: Iterator<Item = &'a Segment>,
|
I: Iterator<Item = &'a Segment>,
|
||||||
{
|
{
|
||||||
let mut used = 0usize;
|
let mut used = 0usize;
|
||||||
let mut current: Vec<ANSIString> = Vec::new();
|
let mut current: Vec<AnsiString> = Vec::new();
|
||||||
let mut chunks: Vec<(Vec<ANSIString>, &FillSegment)> = Vec::new();
|
let mut chunks: Vec<(Vec<AnsiString>, &FillSegment)> = Vec::new();
|
||||||
|
|
||||||
for segment in segments {
|
for segment in segments {
|
||||||
match segment {
|
match segment {
|
||||||
@ -223,7 +223,7 @@ where
|
|||||||
.chain(std::iter::once(fill.ansi_string(fill_size)))
|
.chain(std::iter::once(fill.ansi_string(fill_size)))
|
||||||
})
|
})
|
||||||
.chain(current.into_iter())
|
.chain(current.into_iter())
|
||||||
.collect::<Vec<ANSIString>>()
|
.collect::<Vec<AnsiString>>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::{create_dir, File};
|
use std::fs::{create_dir, File};
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
|
|
||||||
|
@ -108,8 +108,8 @@ fn parse_json(json_file_path: &Path) -> Option<JValue> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use crate::modules::azure::parse_json;
|
use crate::modules::azure::parse_json;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
|
||||||
use ini::Ini;
|
use ini::Ini;
|
||||||
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
@ -172,7 +172,7 @@ impl BatteryInfoProvider for BatteryInfoProviderImpl {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_battery_status() {
|
fn no_battery_status() {
|
||||||
|
@ -64,7 +64,7 @@ fn parse_buf_version(buf_version: &str) -> Option<String> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::parse_buf_version;
|
use super::parse_buf_version;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ fn parse_bun_version(bun_version: String) -> String {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{test::ModuleRenderer, utils::CommandOutput};
|
use crate::{test::ModuleRenderer, utils::CommandOutput};
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
mod test {
|
mod test {
|
||||||
use crate::context::Shell;
|
use crate::context::Shell;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn success_status() {
|
fn success_status() {
|
||||||
|
@ -71,7 +71,7 @@ fn parse_cmake_version(cmake_version: &str) -> Option<String> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -66,13 +66,13 @@ fn undistract_me<'a, 'b>(
|
|||||||
config: &'b CmdDurationConfig,
|
config: &'b CmdDurationConfig,
|
||||||
elapsed: u128,
|
elapsed: u128,
|
||||||
) -> Module<'a> {
|
) -> Module<'a> {
|
||||||
use ansi_term::{unstyle, ANSIStrings};
|
|
||||||
use notify_rust::{Notification, Timeout};
|
use notify_rust::{Notification, Timeout};
|
||||||
|
use nu_ansi_term::{unstyle, AnsiStrings};
|
||||||
|
|
||||||
if config.show_notifications && config.min_time_to_notify as u128 <= elapsed {
|
if config.show_notifications && config.min_time_to_notify as u128 <= elapsed {
|
||||||
let body = format!(
|
let body = format!(
|
||||||
"Command execution {}",
|
"Command execution {}",
|
||||||
unstyle(&ANSIStrings(&module.ansi_strings()))
|
unstyle(&AnsiStrings(&module.ansi_strings()))
|
||||||
);
|
);
|
||||||
|
|
||||||
let timeout = match config.notification_timeout {
|
let timeout = match config.notification_timeout {
|
||||||
@ -98,7 +98,7 @@ fn undistract_me<'a, 'b>(
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn config_blank_duration_1s() {
|
fn config_blank_duration_1s() {
|
||||||
|
@ -75,7 +75,7 @@ fn get_cobol_version(cobol_stdout: &str) -> Option<String> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn not_in_env() {
|
fn not_in_env() {
|
||||||
|
@ -101,7 +101,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -72,7 +72,7 @@ fn parse_crystal_version(crystal_version: &str) -> Option<String> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ fn read_sdk_version_from_daml_yaml(context: &Context) -> Option<String> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Result, Write};
|
use std::io::{Result, Write};
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ fn parse_dart_version(dart_version: &str) -> Option<String> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use crate::utils::CommandOutput;
|
use crate::utils::CommandOutput;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ fn parse_deno_version(deno_version: &str) -> Option<String> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ mod tests {
|
|||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use crate::utils::create_command;
|
use crate::utils::create_command;
|
||||||
use crate::utils::home_dir;
|
use crate::utils::home_dir;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
use std::os::unix::fs::symlink;
|
use std::os::unix::fs::symlink;
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
|
@ -91,7 +91,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
|
|
||||||
|
@ -352,7 +352,7 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use crate::utils::create_command;
|
use crate::utils::create_command;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::{self, OpenOptions};
|
use std::fs::{self, OpenOptions};
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
use tempfile::{self, TempDir};
|
use tempfile::{self, TempDir};
|
||||||
|
@ -91,7 +91,7 @@ fn parse_elixir_version(version: &str) -> Option<(String, String)> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ fn get_env_value(context: &Context, name: &str, default: Option<&str>) -> Option
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::{Color, Style};
|
use nu_ansi_term::{Color, Style};
|
||||||
|
|
||||||
const TEST_VAR_VALUE: &str = "astronauts";
|
const TEST_VAR_VALUE: &str = "astronauts";
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ fn get_erlang_version(context: &Context) -> Option<String> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic() {
|
fn basic() {
|
||||||
|
@ -146,7 +146,7 @@ mod tests {
|
|||||||
use std::fs::{create_dir, File};
|
use std::fs::{create_dir, File};
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
|
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
|
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ fn get_first_grapheme(text: &str) -> &str {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use crate::test::{fixture_repo, FixtureProvider, ModuleRenderer};
|
use crate::test::{fixture_repo, FixtureProvider, ModuleRenderer};
|
||||||
|
@ -78,7 +78,7 @@ fn git_hash(repo: &Repo, config: &GitCommitConfig) -> Option<String> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::{io, str};
|
use std::{io, str};
|
||||||
|
|
||||||
use crate::test::{fixture_repo, FixtureProvider, ModuleRenderer};
|
use crate::test::{fixture_repo, FixtureProvider, ModuleRenderer};
|
||||||
|
@ -116,7 +116,7 @@ mod tests {
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
|
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
|
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ struct StateDescription<'a> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
use std::io::{self, Error, ErrorKind, Write};
|
use std::io::{self, Error, ErrorKind, Write};
|
||||||
|
@ -470,7 +470,7 @@ fn git_status_wsl(_context: &Context, _conf: &GitStatusConfig) -> Option<String>
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use ansi_term::{ANSIStrings, Color};
|
use nu_ansi_term::{AnsiStrings, Color};
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io::{self, prelude::*};
|
use std::io::{self, prelude::*};
|
||||||
@ -832,7 +832,7 @@ mod tests {
|
|||||||
.collect();
|
.collect();
|
||||||
let expected = Some(format!(
|
let expected = Some(format!(
|
||||||
"{} ",
|
"{} ",
|
||||||
ANSIStrings(&[
|
AnsiStrings(&[
|
||||||
Color::Red.bold().paint("[+"),
|
Color::Red.bold().paint("[+"),
|
||||||
Color::Green.paint("1"),
|
Color::Green.paint("1"),
|
||||||
Color::Red.bold().paint("]"),
|
Color::Red.bold().paint("]"),
|
||||||
|
@ -78,7 +78,7 @@ fn parse_go_version(go_stdout: &str) -> Option<String> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ fn is_stack_project(context: &Context) -> bool {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
@ -83,7 +83,7 @@ fn parse_helm_version(helm_stdout: &str) -> Option<String> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ fn graphemes_len(text: &str) -> usize {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use ansi_term::{Color, Style};
|
use nu_ansi_term::{Color, Style};
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
@ -78,7 +78,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::{Color, Style};
|
use nu_ansi_term::{Color, Style};
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
|
|
||||||
macro_rules! get_hostname {
|
macro_rules! get_hostname {
|
||||||
|
@ -90,7 +90,7 @@ fn parse_java_version(java_version_string: &str) -> Option<String> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{test::ModuleRenderer, utils::CommandOutput};
|
use crate::{test::ModuleRenderer, utils::CommandOutput};
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn config_blank_job_0() {
|
fn config_blank_job_0() {
|
||||||
|
@ -76,7 +76,7 @@ fn parse_julia_version(julia_stdout: &str) -> Option<String> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ fn parse_kotlin_version(kotlin_stdout: &str) -> Option<String> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::{create_dir, File};
|
use std::fs::{create_dir, File};
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
|
@ -61,7 +61,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::{Color, Style};
|
use nu_ansi_term::{Color, Style};
|
||||||
|
|
||||||
macro_rules! get_localip {
|
macro_rules! get_localip {
|
||||||
() => {
|
() => {
|
||||||
|
@ -80,7 +80,7 @@ fn parse_lua_version(lua_version: &str) -> Option<String> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ fn parse_nim_version(version_cmd_output: &str) -> Option<&str> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::parse_nim_version;
|
use super::parse_nim_version;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_env_variables() {
|
fn no_env_variables() {
|
||||||
|
@ -117,7 +117,7 @@ fn check_engines_version(nodejs_version: &str, engines_version: Option<String>)
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
@ -112,7 +112,7 @@ fn parse_opam_switch(opam_switch: &str) -> Option<OpamSwitch> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::{parse_opam_switch, SwitchType};
|
use super::{parse_opam_switch, SwitchType};
|
||||||
use crate::{test::ModuleRenderer, utils::CommandOutput};
|
use crate::{test::ModuleRenderer, utils::CommandOutput};
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ fn format_version(version: &str, version_format: &str) -> Option<String> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{test::ModuleRenderer, utils::CommandOutput};
|
use crate::{test::ModuleRenderer, utils::CommandOutput};
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
@ -60,7 +60,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::context::Target;
|
use crate::context::Target;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pulumi_version_release() {
|
fn pulumi_version_release() {
|
||||||
|
@ -58,7 +58,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ fn get_prompt_from_venv(venv_path: &Path) -> Option<String> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::{create_dir_all, File};
|
use std::fs::{create_dir_all, File};
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
@ -101,7 +101,7 @@ fn parse_raku_version(version: &str) -> Option<(String, String)> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ fn parse_r_version(r_version: &str) -> Option<String> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::parse_r_version;
|
use super::parse_r_version;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
@ -85,7 +85,7 @@ fn format_ruby_version(ruby_version: &str, version_format: &str) -> Option<Strin
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ fn parse_scala_version(scala_version_string: &str) -> Option<String> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use crate::context::Shell;
|
use crate::context::Shell;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_none_if_disabled() {
|
fn test_none_if_disabled() {
|
||||||
|
@ -63,7 +63,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use ansi_term::{Color, Style};
|
use nu_ansi_term::{Color, Style};
|
||||||
|
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_env_set() {
|
fn no_env_set() {
|
||||||
|
@ -49,7 +49,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn not_in_env() {
|
fn not_in_env() {
|
||||||
|
@ -225,7 +225,7 @@ fn status_signal_name(signal: SignalNumber) -> Option<&'static str> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
|
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{test::ModuleRenderer, utils::CommandOutput};
|
use crate::{test::ModuleRenderer, utils::CommandOutput};
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_sudo_not_cached() {
|
fn test_sudo_not_cached() {
|
||||||
|
@ -72,7 +72,7 @@ fn parse_swift_version(swift_version: &str) -> Option<String> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::parse_swift_version;
|
use super::parse_swift_version;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ fn parse_terraform_version(version: &str) -> Option<String> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ fn parse_vagrant_version(vagrant_stdout: &str) -> Option<String> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn not_in_env() {
|
fn not_in_env() {
|
||||||
|
@ -70,7 +70,7 @@ fn parse_v_version(v_version: &str) -> Option<String> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::parse_v_version;
|
use super::parse_v_version;
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::test::ModuleRenderer;
|
use crate::test::ModuleRenderer;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use ansi_term::ANSIStrings;
|
|
||||||
use clap::{PossibleValue, ValueEnum};
|
use clap::{PossibleValue, ValueEnum};
|
||||||
|
use nu_ansi_term::AnsiStrings;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
use std::fmt::{self, Debug, Write as FmtWrite};
|
use std::fmt::{self, Debug, Write as FmtWrite};
|
||||||
@ -119,7 +119,7 @@ pub fn get_prompt(context: Context) -> String {
|
|||||||
// continuation prompts normally do not include newlines, but they can
|
// continuation prompts normally do not include newlines, but they can
|
||||||
writeln!(buf).unwrap();
|
writeln!(buf).unwrap();
|
||||||
}
|
}
|
||||||
write!(buf, "{}", ANSIStrings(&module_strings)).unwrap();
|
write!(buf, "{}", AnsiStrings(&module_strings)).unwrap();
|
||||||
|
|
||||||
if context.target == Target::Right {
|
if context.target == Target::Right {
|
||||||
// right prompts generally do not allow newlines
|
// right prompts generally do not allow newlines
|
||||||
@ -163,7 +163,7 @@ pub fn timings(args: Properties) {
|
|||||||
.map(|module| ModuleTiming {
|
.map(|module| ModuleTiming {
|
||||||
name: String::from(module.get_name().as_str()),
|
name: String::from(module.get_name().as_str()),
|
||||||
name_len: module.get_name().width_graphemes(),
|
name_len: module.get_name().width_graphemes(),
|
||||||
value: ansi_term::ANSIStrings(&module.ansi_strings())
|
value: nu_ansi_term::AnsiStrings(&module.ansi_strings())
|
||||||
.to_string()
|
.to_string()
|
||||||
.replace('\n', "\\n"),
|
.replace('\n', "\\n"),
|
||||||
duration: module.duration,
|
duration: module.duration,
|
||||||
@ -212,7 +212,7 @@ pub fn explain(args: Properties) {
|
|||||||
.map(|module| {
|
.map(|module| {
|
||||||
let value = module.get_segments().join("");
|
let value = module.get_segments().join("");
|
||||||
ModuleInfo {
|
ModuleInfo {
|
||||||
value: ansi_term::ANSIStrings(&module.ansi_strings()).to_string(),
|
value: nu_ansi_term::AnsiStrings(&module.ansi_strings()).to_string(),
|
||||||
value_len: value.width_graphemes()
|
value_len: value.width_graphemes()
|
||||||
+ format_duration(&module.duration).width_graphemes(),
|
+ format_duration(&module.duration).width_graphemes(),
|
||||||
desc: module.get_description().clone(),
|
desc: module.get_description().clone(),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::print::{Grapheme, UnicodeWidthGraphemes};
|
use crate::print::{Grapheme, UnicodeWidthGraphemes};
|
||||||
use ansi_term::{ANSIString, Style};
|
use nu_ansi_term::{AnsiString, Style};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
|
|
||||||
@ -14,11 +14,11 @@ pub struct TextSegment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TextSegment {
|
impl TextSegment {
|
||||||
// Returns the ANSIString of the segment value
|
// Returns the AnsiString of the segment value
|
||||||
fn ansi_string(&self) -> ANSIString {
|
fn ansi_string(&self) -> AnsiString {
|
||||||
match self.style {
|
match self.style {
|
||||||
Some(style) => style.paint(&self.value),
|
Some(style) => style.paint(&self.value),
|
||||||
None => ANSIString::from(&self.value),
|
None => AnsiString::from(&self.value),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -34,8 +34,8 @@ pub struct FillSegment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl FillSegment {
|
impl FillSegment {
|
||||||
// Returns the ANSIString of the segment value, not including its prefix and suffix
|
// Returns the AnsiString of the segment value, not including its prefix and suffix
|
||||||
pub fn ansi_string(&self, width: Option<usize>) -> ANSIString {
|
pub fn ansi_string(&self, width: Option<usize>) -> AnsiString {
|
||||||
let s = match width {
|
let s = match width {
|
||||||
Some(w) => self
|
Some(w) => self
|
||||||
.value
|
.value
|
||||||
@ -54,7 +54,7 @@ impl FillSegment {
|
|||||||
};
|
};
|
||||||
match self.style {
|
match self.style {
|
||||||
Some(style) => style.paint(s),
|
Some(style) => style.paint(s),
|
||||||
None => ANSIString::from(s),
|
None => AnsiString::from(s),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ impl FillSegment {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod fill_seg_tests {
|
mod fill_seg_tests {
|
||||||
use super::FillSegment;
|
use super::FillSegment;
|
||||||
use ansi_term::Color;
|
use nu_ansi_term::Color;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ansi_string_width() {
|
fn ansi_string_width() {
|
||||||
@ -158,12 +158,12 @@ impl Segment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the ANSIString of the segment value, not including its prefix and suffix
|
// Returns the AnsiString of the segment value, not including its prefix and suffix
|
||||||
pub fn ansi_string(&self) -> ANSIString {
|
pub fn ansi_string(&self) -> AnsiString {
|
||||||
match self {
|
match self {
|
||||||
Self::Fill(fs) => fs.ansi_string(None),
|
Self::Fill(fs) => fs.ansi_string(None),
|
||||||
Self::Text(ts) => ts.ansi_string(),
|
Self::Text(ts) => ts.ansi_string(),
|
||||||
Self::LineTerm => ANSIString::from(LINE_TERMINATOR_STRING),
|
Self::LineTerm => AnsiString::from(LINE_TERMINATOR_STRING),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user