aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2023-03-26 00:08:59 -0400
committerJesse Luehrs <doy@tozt.net>2023-03-26 00:09:33 -0400
commitf252f4c6595421339cb3119f1ca8ef491077f365 (patch)
tree8bcbaf555e2e33615446c90923bf8557d02d5007
parentb840c96b787c7f8e5cfca2318516838fb743b61e (diff)
downloadfancy-prompt-f252f4c6595421339cb3119f1ca8ef491077f365.tar.gz
fancy-prompt-f252f4c6595421339cb3119f1ca8ef491077f365.zip
bump to 2021 edition
-rw-r--r--Cargo.toml1
-rw-r--r--src/args.rs2
-rw-r--r--src/colors.rs20
-rw-r--r--src/data.rs18
-rw-r--r--src/prompt.rs30
-rw-r--r--src/vcs/git.rs2
-rw-r--r--src/vcs/mod.rs2
7 files changed, 35 insertions, 40 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 8e7a25c..d0b36d0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,6 +6,7 @@ license = "MIT"
version = "0.1.6"
authors = ["Jesse Luehrs <doy@tozt.net>"]
exclude = ["screenshots/*"]
+edition = "2021"
[badges]
travis-ci = { repository = "doy/fancy-prompt", branch = "master" }
diff --git a/src/args.rs b/src/args.rs
index 90e33b7..bae31f2 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -1,6 +1,6 @@
use clap;
-use colors;
+use crate::colors;
pub struct CommandLineOptions {
pub shell: colors::ShellType,
diff --git a/src/colors.rs b/src/colors.rs
index bb1744c..0e53fdc 100644
--- a/src/colors.rs
+++ b/src/colors.rs
@@ -97,7 +97,7 @@ impl Colors {
pub fn print<W: std::io::Write>(
&self,
- t: &mut term::Terminal<Output=W>,
+ t: &mut dyn term::Terminal<Output=W>,
color: &str,
text: &str,
) {
@@ -107,7 +107,7 @@ impl Colors {
pub fn pad<W: std::io::Write>(
&self,
- t: &mut term::Terminal<Output=W>,
+ t: &mut dyn term::Terminal<Output=W>,
len: usize,
) {
write!(t, "{}", " ".repeat(len)).unwrap();
@@ -115,14 +115,14 @@ impl Colors {
pub fn newline<W: std::io::Write>(
&self,
- t: &mut term::Terminal<Output=W>,
+ t: &mut dyn term::Terminal<Output=W>,
) {
write!(t, "{}", "\n").unwrap();
}
pub fn print_host<W: std::io::Write>(
&self,
- t: &mut term::Terminal<Output=W>,
+ t: &mut dyn term::Terminal<Output=W>,
host: Option<&str>,
text: &str,
) {
@@ -134,7 +134,7 @@ impl Colors {
pub fn print_user<W: std::io::Write>(
&self,
- t: &mut term::Terminal<Output=W>,
+ t: &mut dyn term::Terminal<Output=W>,
user: Option<&str>,
text: &str,
) {
@@ -146,7 +146,7 @@ impl Colors {
fn print_with_color<W: std::io::Write>(
&self,
- t: &mut term::Terminal<Output=W>,
+ t: &mut dyn term::Terminal<Output=W>,
color: Option<&term::color::Color>,
text: &str,
) {
@@ -157,7 +157,7 @@ impl Colors {
fn print_reset<W: std::io::Write>(
&self,
- t: &mut term::Terminal<Output=W>,
+ t: &mut dyn term::Terminal<Output=W>,
) {
self.print_wrapped(t, |t| {
t.reset().unwrap();
@@ -166,7 +166,7 @@ impl Colors {
fn print_color<W: std::io::Write>(
&self,
- t: &mut term::Terminal<Output=W>,
+ t: &mut dyn term::Terminal<Output=W>,
color: Option<&term::color::Color>,
) {
self.print_wrapped(t, |t| {
@@ -190,11 +190,11 @@ impl Colors {
fn print_wrapped<W: std::io::Write, T>(
&self,
- t: &mut term::Terminal<Output=W>,
+ t: &mut dyn term::Terminal<Output=W>,
printer: T,
)
where
- T: FnOnce(&mut term::Terminal<Output=W>),
+ T: FnOnce(&mut dyn term::Terminal<Output=W>),
{
match self.shell_type {
ShellType::Bash => {
diff --git a/src/data.rs b/src/data.rs
index e1a77a0..322f373 100644
--- a/src/data.rs
+++ b/src/data.rs
@@ -1,13 +1,7 @@
-use chrono;
-use hostname;
-use term_size;
-use std;
-use users;
-
-use args;
-use colors;
-use power;
-use vcs;
+use crate::args;
+use crate::colors;
+use crate::power;
+use crate::vcs;
pub struct PromptData {
pub shell: colors::ShellType,
@@ -20,7 +14,7 @@ pub struct PromptData {
pub is_root: bool,
pub time: chrono::DateTime<chrono::Local>,
pub power_info: power::PowerInfo,
- pub vcs_info: Option<Box<vcs::VcsInfo>>,
+ pub vcs_info: Option<Box<dyn vcs::VcsInfo>>,
}
pub fn collect(opts: args::CommandLineOptions) -> PromptData {
@@ -107,6 +101,6 @@ fn power_info() -> power::PowerInfo {
power::PowerInfo::new()
}
-fn vcs_info() -> Option<Box<vcs::VcsInfo>> {
+fn vcs_info() -> Option<Box<dyn vcs::VcsInfo>> {
vcs::detect()
}
diff --git a/src/prompt.rs b/src/prompt.rs
index 4b207db..39411f0 100644
--- a/src/prompt.rs
+++ b/src/prompt.rs
@@ -4,10 +4,10 @@ use term;
use std::fmt::Write;
-use colors;
-use data;
-use sys;
-use vcs;
+use crate::colors;
+use crate::data;
+use crate::sys;
+use crate::vcs;
pub struct Prompt {
colors: colors::Colors,
@@ -113,7 +113,7 @@ impl Prompt {
fn display_path<W: std::io::Write>(
&self,
- t: &mut term::Terminal<Output=W>,
+ t: &mut dyn term::Terminal<Output=W>,
path: &str,
path_color: &str,
vcs: Option<&str>,
@@ -130,7 +130,7 @@ impl Prompt {
fn display_border<W: std::io::Write>(
&self,
- t: &mut term::Terminal<Output=W>,
+ t: &mut dyn term::Terminal<Output=W>,
len: usize
) {
self.colors.print(t, "default", &"-".repeat(len));
@@ -138,7 +138,7 @@ impl Prompt {
fn display_battery<W: std::io::Write>(
&self,
- t: &mut term::Terminal<Output=W>,
+ t: &mut dyn term::Terminal<Output=W>,
len: usize
) {
self.print_host(t, "{");
@@ -171,7 +171,7 @@ impl Prompt {
fn display_identity<W: std::io::Write>(
&self,
- t: &mut term::Terminal<Output=W>,
+ t: &mut dyn term::Terminal<Output=W>,
user: &str,
host: &str,
) {
@@ -182,7 +182,7 @@ impl Prompt {
fn display_time<W: std::io::Write>(
&self,
- t: &mut term::Terminal<Output=W>,
+ t: &mut dyn term::Terminal<Output=W>,
) {
self.print_host(t, "[");
self.colors.print(
@@ -195,7 +195,7 @@ impl Prompt {
fn display_error_code<W: std::io::Write>(
&self,
- t: &mut term::Terminal<Output=W>,
+ t: &mut dyn term::Terminal<Output=W>,
) {
let error_code_color = if self.data.error_code == 0 {
"default"
@@ -212,7 +212,7 @@ impl Prompt {
fn display_prompt<W: std::io::Write>(
&self,
- t: &mut term::Terminal<Output=W>,
+ t: &mut dyn term::Terminal<Output=W>,
) {
let prompt = if self.data.is_root {
"#"
@@ -233,7 +233,7 @@ impl Prompt {
fn print_host<W: std::io::Write>(
&self,
- t: &mut term::Terminal<Output=W>,
+ t: &mut dyn term::Terminal<Output=W>,
text: &str
) {
self.colors.print_host(t, self.hostname(), text);
@@ -241,7 +241,7 @@ impl Prompt {
fn print_user<W: std::io::Write>(
&self,
- t: &mut term::Terminal<Output=W>,
+ t: &mut dyn term::Terminal<Output=W>,
text: &str
) {
self.colors.print_user(t, self.user(), text);
@@ -292,7 +292,7 @@ fn path_color(path: Option<&std::path::Path>) -> String {
.unwrap_or_else(|| String::from("path_not_exist"))
}
-fn format_vcs(vcs_info: Option<&vcs::VcsInfo>) -> Option<String> {
+fn format_vcs(vcs_info: Option<&dyn vcs::VcsInfo>) -> Option<String> {
vcs_info.as_ref().map(|vcs_info| {
let mut vcs = String::new();
@@ -354,7 +354,7 @@ fn format_vcs(vcs_info: Option<&vcs::VcsInfo>) -> Option<String> {
})
}
-fn vcs_color(vcs_info: Option<&vcs::VcsInfo>) -> String {
+fn vcs_color(vcs_info: Option<&dyn vcs::VcsInfo>) -> String {
vcs_info
.as_ref()
.map(|vcs_info| {
diff --git a/src/vcs/git.rs b/src/vcs/git.rs
index c745c46..5b8ad96 100644
--- a/src/vcs/git.rs
+++ b/src/vcs/git.rs
@@ -185,7 +185,7 @@ impl super::VcsInfo for GitInfo {
}
}
-pub fn detect() -> Option<Box<super::VcsInfo>> {
+pub fn detect() -> Option<Box<dyn super::VcsInfo>> {
start_talking_about_time!("git::detect");
let git = git2::Repository::open_from_env().ok();
diff --git a/src/vcs/mod.rs b/src/vcs/mod.rs
index b7a9fc7..e672ec6 100644
--- a/src/vcs/mod.rs
+++ b/src/vcs/mod.rs
@@ -38,7 +38,7 @@ pub trait VcsInfo {
}
}
-pub fn detect() -> Option<Box<VcsInfo>> {
+pub fn detect() -> Option<Box<dyn VcsInfo>> {
if let Some(git) = git::detect() {
Some(git)
}