mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-11-24 21:57:41 +00:00
chore(clippy): fix new clippy lints (#3294)
This commit is contained in:
parent
76c7baac7b
commit
77182a9a22
@ -3,13 +3,7 @@ use crate::config::ModuleConfig;
|
|||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use starship_module_config_derive::ModuleConfig;
|
use starship_module_config_derive::ModuleConfig;
|
||||||
|
|
||||||
#[derive(Clone, ModuleConfig, Serialize)]
|
#[derive(Clone, ModuleConfig, Serialize, Default)]
|
||||||
pub struct LineBreakConfig {
|
pub struct LineBreakConfig {
|
||||||
pub disabled: bool,
|
pub disabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for LineBreakConfig {
|
|
||||||
fn default() -> Self {
|
|
||||||
LineBreakConfig { disabled: false }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -44,7 +44,7 @@ impl GcloudContext {
|
|||||||
.skip(1)
|
.skip(1)
|
||||||
.take_while(|line| !line.starts_with('['))
|
.take_while(|line| !line.starts_with('['))
|
||||||
.find(|line| line.starts_with("account"))?;
|
.find(|line| line.starts_with("account"))?;
|
||||||
let account = account_line.splitn(2, '=').nth(1)?.trim();
|
let account = account_line.split_once('=')?.1.trim();
|
||||||
let mut segments = account.splitn(2, '@');
|
let mut segments = account.splitn(2, '@');
|
||||||
Some((
|
Some((
|
||||||
segments.next().map(String::from)?,
|
segments.next().map(String::from)?,
|
||||||
@ -60,7 +60,7 @@ impl GcloudContext {
|
|||||||
.skip(1)
|
.skip(1)
|
||||||
.take_while(|line| !line.starts_with('['))
|
.take_while(|line| !line.starts_with('['))
|
||||||
.find(|line| line.starts_with("project"))?;
|
.find(|line| line.starts_with("project"))?;
|
||||||
let project = project_line.splitn(2, '=').nth(1)?.trim();
|
let project = project_line.split_once('=')?.1.trim();
|
||||||
Some(project.to_string())
|
Some(project.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ impl GcloudContext {
|
|||||||
.skip(1)
|
.skip(1)
|
||||||
.take_while(|line| !line.starts_with('['))
|
.take_while(|line| !line.starts_with('['))
|
||||||
.find(|line| line.starts_with("region"))?;
|
.find(|line| line.starts_with("region"))?;
|
||||||
let region = region_line.splitn(2, '=').nth(1)?.trim();
|
let region = region_line.split_once('=')?.1.trim();
|
||||||
Some(region.to_string())
|
Some(region.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,8 +242,8 @@ mod tests {
|
|||||||
"",
|
"",
|
||||||
format!(
|
format!(
|
||||||
"branch: {} {} ",
|
"branch: {} {} ",
|
||||||
Color::Blue.bold().paint("1337_hello_world").to_string(),
|
Color::Blue.bold().paint("1337_hello_world"),
|
||||||
Color::Red.paint("THE COLORS").to_string()
|
Color::Red.paint("THE COLORS")
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -257,10 +257,7 @@ mod tests {
|
|||||||
symbol = "git: "
|
symbol = "git: "
|
||||||
style = "green"
|
style = "green"
|
||||||
"#,
|
"#,
|
||||||
format!(
|
format!("git: {}", Color::Green.paint("1337_hello_world"),),
|
||||||
"git: {}",
|
|
||||||
Color::Green.paint("1337_hello_world").to_string(),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,10 +146,7 @@ mod tests {
|
|||||||
|
|
||||||
let expected = Some(format!(
|
let expected = Some(format!(
|
||||||
"{} ",
|
"{} ",
|
||||||
Color::Green
|
Color::Green.bold().paint(format!("({})", expected_hash))
|
||||||
.bold()
|
|
||||||
.paint(format!("({})", expected_hash))
|
|
||||||
.to_string()
|
|
||||||
));
|
));
|
||||||
|
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
@ -179,10 +176,7 @@ mod tests {
|
|||||||
|
|
||||||
let expected = Some(format!(
|
let expected = Some(format!(
|
||||||
"{} ",
|
"{} ",
|
||||||
Color::Green
|
Color::Green.bold().paint(format!("({})", expected_hash))
|
||||||
.bold()
|
|
||||||
.paint(format!("({})", expected_hash))
|
|
||||||
.to_string()
|
|
||||||
));
|
));
|
||||||
|
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
@ -226,10 +220,7 @@ mod tests {
|
|||||||
|
|
||||||
let expected = Some(format!(
|
let expected = Some(format!(
|
||||||
"{} ",
|
"{} ",
|
||||||
Color::Green
|
Color::Green.bold().paint(format!("({})", expected_hash))
|
||||||
.bold()
|
|
||||||
.paint(format!("({})", expected_hash))
|
|
||||||
.to_string()
|
|
||||||
));
|
));
|
||||||
|
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
@ -272,7 +263,6 @@ mod tests {
|
|||||||
Color::Green
|
Color::Green
|
||||||
.bold()
|
.bold()
|
||||||
.paint(format!("({})", expected_output.trim()))
|
.paint(format!("({})", expected_output.trim()))
|
||||||
.to_string()
|
|
||||||
));
|
));
|
||||||
|
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
@ -324,7 +314,6 @@ mod tests {
|
|||||||
Color::Green
|
Color::Green
|
||||||
.bold()
|
.bold()
|
||||||
.paint(format!("({})", expected_output.trim()))
|
.paint(format!("({})", expected_output.trim()))
|
||||||
.to_string()
|
|
||||||
));
|
));
|
||||||
|
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
@ -396,7 +385,6 @@ mod tests {
|
|||||||
Color::Green
|
Color::Green
|
||||||
.bold()
|
.bold()
|
||||||
.paint(format!("({})", expected_output.trim()))
|
.paint(format!("({})", expected_output.trim()))
|
||||||
.to_string()
|
|
||||||
));
|
));
|
||||||
|
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
|
@ -62,10 +62,10 @@ fn parse_go_version(go_stdout: &str) -> Option<String> {
|
|||||||
// go version go1.13.3 linux/amd64
|
// go version go1.13.3 linux/amd64
|
||||||
|
|
||||||
let version = go_stdout
|
let version = go_stdout
|
||||||
// split into ["", "1.12.4 linux/amd64"]
|
// split into ("", "1.12.4 linux/amd64")
|
||||||
.splitn(2, "go version go")
|
.split_once("go version go")?
|
||||||
// return "1.12.4 linux/amd64"
|
// return "1.12.4 linux/amd64"
|
||||||
.nth(1)?
|
.1
|
||||||
// split into ["1.12.4", "linux/amd64"]
|
// split into ["1.12.4", "linux/amd64"]
|
||||||
.split_whitespace()
|
.split_whitespace()
|
||||||
// return "1.12.4"
|
// return "1.12.4"
|
||||||
|
@ -66,10 +66,10 @@ fn parse_helm_version(helm_stdout: &str) -> Option<String> {
|
|||||||
// `helm version --short --client` output looks like this for Helm 2:
|
// `helm version --short --client` output looks like this for Helm 2:
|
||||||
// Client: v2.16.9+g8ad7037
|
// Client: v2.16.9+g8ad7037
|
||||||
let version = helm_stdout
|
let version = helm_stdout
|
||||||
// split into ["v3.1.1","gafe7058"] or ["Client: v3.1.1","gafe7058"]
|
// split into ("v3.1.1","gafe7058") or ("Client: v3.1.1","gafe7058")
|
||||||
.splitn(2, '+')
|
.split_once('+')
|
||||||
// return "v3.1.1" or "Client: v3.1.1"
|
// return "v3.1.1" or "Client: v3.1.1"
|
||||||
.next()?
|
.map_or(helm_stdout, |x| x.0)
|
||||||
// return "v3.1.1" or " v3.1.1"
|
// return "v3.1.1" or " v3.1.1"
|
||||||
.trim_start_matches("Client: ")
|
.trim_start_matches("Client: ")
|
||||||
// return "v3.1.1"
|
// return "v3.1.1"
|
||||||
|
@ -62,10 +62,10 @@ fn parse_julia_version(julia_stdout: &str) -> Option<String> {
|
|||||||
// julia version 1.4.0
|
// julia version 1.4.0
|
||||||
|
|
||||||
let version = julia_stdout
|
let version = julia_stdout
|
||||||
// split into ["", "1.4.0"]
|
// split into ("", "1.4.0")
|
||||||
.splitn(2, "julia version")
|
.split_once("julia version")?
|
||||||
// return "1.4.0"
|
// return "1.4.0"
|
||||||
.nth(1)?
|
.1
|
||||||
.split_whitespace()
|
.split_whitespace()
|
||||||
.next()?;
|
.next()?;
|
||||||
|
|
||||||
|
@ -149,10 +149,10 @@ fn format_exit_code<'a>(
|
|||||||
.map(|variable| match variable {
|
.map(|variable| match variable {
|
||||||
"status" => Some(Ok(exit_code)),
|
"status" => Some(Ok(exit_code)),
|
||||||
"int" => Some(Ok(exit_code)),
|
"int" => Some(Ok(exit_code)),
|
||||||
"maybe_int" => Ok(maybe_exit_code_number.as_deref()).transpose(),
|
"maybe_int" => Ok(maybe_exit_code_number).transpose(),
|
||||||
"common_meaning" => Ok(common_meaning.as_deref()).transpose(),
|
"common_meaning" => Ok(common_meaning).transpose(),
|
||||||
"signal_number" => Ok(signal_number.as_deref()).transpose(),
|
"signal_number" => Ok(signal_number.as_deref()).transpose(),
|
||||||
"signal_name" => Ok(signal_name.as_deref()).transpose(),
|
"signal_name" => Ok(signal_name).transpose(),
|
||||||
"pipestatus" => {
|
"pipestatus" => {
|
||||||
let pipestatus = pipestatus.unwrap_or_else(|| {
|
let pipestatus = pipestatus.unwrap_or_else(|| {
|
||||||
// We might enter this case if pipestatus hasn't
|
// We might enter this case if pipestatus hasn't
|
||||||
|
Loading…
Reference in New Issue
Block a user