Skip to content

Commit c77d73c

Browse files
committed
chore: fix cargo fmt
1 parent cb94b42 commit c77d73c

File tree

3 files changed

+92
-42
lines changed

3 files changed

+92
-42
lines changed

crates/atuin-client/src/theme.rs

Lines changed: 67 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ impl Theme {
8787
self.styles[ALERT_TYPES.get(&severity).unwrap()]
8888
}
8989

90-
pub fn new(name: String, parent: Option<String>, styles: HashMap<Meaning, ContentStyle>) -> Theme {
90+
pub fn new(
91+
name: String,
92+
parent: Option<String>,
93+
styles: HashMap<Meaning, ContentStyle>,
94+
) -> Theme {
9195
Theme {
9296
name,
9397
parent,
@@ -136,7 +140,7 @@ impl Theme {
136140
);
137141
}
138142
ContentStyle::default()
139-
})
143+
}),
140144
)
141145
})
142146
.collect();
@@ -145,7 +149,11 @@ impl Theme {
145149

146150
// Boil down a meaning-color hashmap into a theme, by taking the defaults
147151
// for any unknown colors
148-
fn from_map(name: String, parent: Option<&Theme>, overrides: &HashMap<Meaning, ContentStyle>) -> Theme {
152+
fn from_map(
153+
name: String,
154+
parent: Option<&Theme>,
155+
overrides: &HashMap<Meaning, ContentStyle>,
156+
) -> Theme {
149157
let styles = match parent {
150158
Some(theme) => Box::new(theme.styles.clone()),
151159
None => Box::new(DEFAULT_THEME.styles.clone()),
@@ -198,7 +206,7 @@ impl StyleFactory {
198206
fn from_fg_string(name: &str) -> Result<ContentStyle, String> {
199207
match from_string(name) {
200208
Ok(color) => Ok(Self::from_fg_color(color)),
201-
Err(err) => Err(err)
209+
Err(err) => Err(err),
202210
}
203211
}
204212

@@ -240,14 +248,26 @@ lazy_static! {
240248
None,
241249
HashMap::from([
242250
(Meaning::AlertError, StyleFactory::from_fg_color(Color::Red)),
243-
(Meaning::AlertWarn, StyleFactory::from_fg_color(Color::Yellow)),
244-
(Meaning::AlertInfo, StyleFactory::from_fg_color(Color::Green)),
245-
(Meaning::Annotation, StyleFactory::from_fg_color(Color::DarkGrey)),
251+
(
252+
Meaning::AlertWarn,
253+
StyleFactory::from_fg_color(Color::Yellow),
254+
),
255+
(
256+
Meaning::AlertInfo,
257+
StyleFactory::from_fg_color(Color::Green),
258+
),
259+
(
260+
Meaning::Annotation,
261+
StyleFactory::from_fg_color(Color::DarkGrey),
262+
),
246263
(Meaning::Guidance, StyleFactory::from_fg_color(Color::Blue)),
247-
(Meaning::Important, StyleFactory::from_fg_color(Color::White)),
264+
(
265+
Meaning::Important,
266+
StyleFactory::from_fg_color(Color::White),
267+
),
248268
(Meaning::Muted, StyleFactory::from_fg_color(Color::Grey)),
249269
(Meaning::Base, ContentStyle::default()),
250-
])
270+
]),
251271
)
252272
};
253273
static ref BUILTIN_THEMES: HashMap<&'static str, Theme> = {
@@ -256,21 +276,42 @@ lazy_static! {
256276
(
257277
"autumn",
258278
HashMap::from([
259-
(Meaning::AlertError, StyleFactory::known_fg_string("saddlebrown")),
260-
(Meaning::AlertWarn, StyleFactory::known_fg_string("darkorange")),
279+
(
280+
Meaning::AlertError,
281+
StyleFactory::known_fg_string("saddlebrown"),
282+
),
283+
(
284+
Meaning::AlertWarn,
285+
StyleFactory::known_fg_string("darkorange"),
286+
),
261287
(Meaning::AlertInfo, StyleFactory::known_fg_string("gold")),
262-
(Meaning::Annotation, StyleFactory::from_fg_color(Color::DarkGrey)),
288+
(
289+
Meaning::Annotation,
290+
StyleFactory::from_fg_color(Color::DarkGrey),
291+
),
263292
(Meaning::Guidance, StyleFactory::known_fg_string("brown")),
264293
]),
265294
),
266295
(
267296
"marine",
268297
HashMap::from([
269-
(Meaning::AlertError, StyleFactory::known_fg_string("yellowgreen")),
298+
(
299+
Meaning::AlertError,
300+
StyleFactory::known_fg_string("yellowgreen"),
301+
),
270302
(Meaning::AlertWarn, StyleFactory::known_fg_string("cyan")),
271-
(Meaning::AlertInfo, StyleFactory::known_fg_string("turquoise")),
272-
(Meaning::Annotation, StyleFactory::known_fg_string("steelblue")),
273-
(Meaning::Base, StyleFactory::known_fg_string("lightsteelblue")),
303+
(
304+
Meaning::AlertInfo,
305+
StyleFactory::known_fg_string("turquoise"),
306+
),
307+
(
308+
Meaning::Annotation,
309+
StyleFactory::known_fg_string("steelblue"),
310+
),
311+
(
312+
Meaning::Base,
313+
StyleFactory::known_fg_string("lightsteelblue"),
314+
),
274315
(Meaning::Guidance, StyleFactory::known_fg_string("teal")),
275316
]),
276317
),
@@ -430,7 +471,10 @@ mod theme_tests {
430471
let mytheme = Theme::new(
431472
"mytheme".to_string(),
432473
None,
433-
HashMap::from([(Meaning::AlertError, StyleFactory::known_fg_string("yellowgreen"))]),
474+
HashMap::from([(
475+
Meaning::AlertError,
476+
StyleFactory::known_fg_string("yellowgreen"),
477+
)]),
434478
);
435479
manager.loaded_themes.insert("mytheme".to_string(), mytheme);
436480
let theme = manager.load_theme("mytheme", None);
@@ -473,16 +517,10 @@ mod theme_tests {
473517
);
474518

475519
// Does not fall back to any color.
476-
assert_eq!(
477-
theme.as_style(Meaning::AlertInfo).foreground_color,
478-
None
479-
);
520+
assert_eq!(theme.as_style(Meaning::AlertInfo).foreground_color, None);
480521

481522
// Even for the base.
482-
assert_eq!(
483-
theme.as_style(Meaning::Base).foreground_color,
484-
None
485-
);
523+
assert_eq!(theme.as_style(Meaning::Base).foreground_color, None);
486524

487525
// Falls back to red as meaning missing from theme, so picks base default.
488526
assert_eq!(
@@ -536,7 +574,10 @@ mod theme_tests {
536574
assert_eq!(theme.get_warning().foreground_color.unwrap(), Color::Yellow);
537575
assert_eq!(theme.get_info().foreground_color.unwrap(), Color::Green);
538576
assert_eq!(theme.get_base().foreground_color, None);
539-
assert_eq!(theme.get_alert(log::Level::Error).foreground_color.unwrap(), Color::Red)
577+
assert_eq!(
578+
theme.get_alert(log::Level::Error).foreground_color.unwrap(),
579+
Color::Red
580+
)
540581
}
541582

542583
#[test]

crates/atuin-history/src/stats.rs

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use std::collections::{HashMap, HashSet};
22

3-
use crossterm::style::{ResetColor, SetAttribute, SetForegroundColor, Color};
3+
use crossterm::style::{Color, ResetColor, SetAttribute, SetForegroundColor};
44
use serde::{Deserialize, Serialize};
55
use unicode_segmentation::UnicodeSegmentation;
66

7-
use atuin_client::{history::History, settings::Settings, theme::Theme, theme::Meaning};
7+
use atuin_client::{history::History, settings::Settings, theme::Meaning, theme::Theme};
88

99
#[derive(Debug, Serialize, Deserialize)]
1010
pub struct Stats {
@@ -128,31 +128,40 @@ pub fn pretty_print(stats: Stats, ngram_size: usize, theme: &Theme) {
128128
for (command, count) in stats.top {
129129
let gray = SetForegroundColor(match theme.as_style(Meaning::Muted).foreground_color {
130130
Some(color) => color,
131-
None => Color::Grey
131+
None => Color::Grey,
132132
});
133133
let bold = SetAttribute(crossterm::style::Attribute::Bold);
134134

135135
let in_ten = 10 * count / max;
136136

137137
print!("[");
138-
print!("{}", SetForegroundColor(match theme.get_error().foreground_color {
139-
Some(color) => color,
140-
None => Color::Red
141-
}));
138+
print!(
139+
"{}",
140+
SetForegroundColor(match theme.get_error().foreground_color {
141+
Some(color) => color,
142+
None => Color::Red,
143+
})
144+
);
142145

143146
for i in 0..in_ten {
144147
if i == 2 {
145-
print!("{}", SetForegroundColor(match theme.get_warning().foreground_color {
146-
Some(color) => color,
147-
None => Color::Yellow
148-
}));
148+
print!(
149+
"{}",
150+
SetForegroundColor(match theme.get_warning().foreground_color {
151+
Some(color) => color,
152+
None => Color::Yellow,
153+
})
154+
);
149155
}
150156

151157
if i == 5 {
152-
print!("{}", SetForegroundColor(match theme.get_info().foreground_color {
153-
Some(color) => color,
154-
None => Color::Green
155-
}));
158+
print!(
159+
"{}",
160+
SetForegroundColor(match theme.get_info().foreground_color {
161+
Some(color) => color,
162+
None => Color::Green,
163+
})
164+
);
156165
}
157166

158167
print!("▮");

crates/atuin/src/command/client/search/interactive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ impl State {
775775
let style: Style = theme.as_style(Meaning::Base).into();
776776
Paragraph::new(Text::from(Span::styled(
777777
format!("Atuin v{VERSION}"),
778-
style.add_modifier(Modifier::BOLD)
778+
style.add_modifier(Modifier::BOLD),
779779
)))
780780
};
781781
title.alignment(Alignment::Left)

0 commit comments

Comments
 (0)