mirror of
https://github.com/RGBCube/alejandra
synced 2025-07-31 12:37:45 +00:00
refactor: apply formatter
This commit is contained in:
parent
f5a22afd2a
commit
86949fa142
1 changed files with 16 additions and 14 deletions
|
@ -2,7 +2,7 @@ use clap::Parser;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(crate) struct FormattedPath {
|
pub(crate) struct FormattedPath {
|
||||||
pub path: String,
|
pub path: String,
|
||||||
pub status: alejandra::format::Status,
|
pub status: alejandra::format::Status,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,25 +180,25 @@ pub(crate) fn tui(
|
||||||
} else {
|
} else {
|
||||||
paths_unchanged += 1;
|
paths_unchanged += 1;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
alejandra::format::Status::Error(_) => {
|
alejandra::format::Status::Error(_) => {
|
||||||
paths_with_errors += 1;
|
paths_with_errors += 1;
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
formatted_paths.push_back(formatted_path);
|
formatted_paths.push_back(formatted_path);
|
||||||
}
|
},
|
||||||
Event::FormattingFinished => {
|
Event::FormattingFinished => {
|
||||||
finished = true;
|
finished = true;
|
||||||
}
|
},
|
||||||
Event::Input(key) => {
|
Event::Input(key) => {
|
||||||
if let termion::event::Key::Ctrl('c') = key {
|
if let termion::event::Key::Ctrl('c') = key {
|
||||||
return Err(std::io::ErrorKind::Interrupted.into());
|
return Err(std::io::ErrorKind::Interrupted.into());
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
Event::Tick => {
|
Event::Tick => {
|
||||||
break;
|
break;
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,14 +293,14 @@ pub(crate) fn tui(
|
||||||
tui::style::Style::default()
|
tui::style::Style::default()
|
||||||
.fg(tui::style::Color::Green),
|
.fg(tui::style::Color::Green),
|
||||||
)
|
)
|
||||||
}
|
},
|
||||||
alejandra::format::Status::Error(_) => {
|
alejandra::format::Status::Error(_) => {
|
||||||
tui::text::Span::styled(
|
tui::text::Span::styled(
|
||||||
"ERROR ",
|
"ERROR ",
|
||||||
tui::style::Style::default()
|
tui::style::Style::default()
|
||||||
.fg(tui::style::Color::Red),
|
.fg(tui::style::Color::Red),
|
||||||
)
|
)
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
tui::text::Span::raw(formatted_path.path.clone()),
|
tui::text::Span::raw(formatted_path.path.clone()),
|
||||||
])
|
])
|
||||||
|
@ -340,7 +340,7 @@ pub fn main() -> std::io::Result<()> {
|
||||||
let formatted_paths = match &include[..] {
|
let formatted_paths = match &include[..] {
|
||||||
&[] | &["-"] => {
|
&[] | &["-"] => {
|
||||||
vec![crate::cli::stdin(args.quiet)]
|
vec![crate::cli::stdin(args.quiet)]
|
||||||
}
|
},
|
||||||
include => {
|
include => {
|
||||||
let paths = crate::find::nix_files(include, &args.exclude);
|
let paths = crate::find::nix_files(include, &args.exclude);
|
||||||
|
|
||||||
|
@ -353,7 +353,7 @@ pub fn main() -> std::io::Result<()> {
|
||||||
} else {
|
} else {
|
||||||
crate::cli::simple(paths, in_place, args.quiet)
|
crate::cli::simple(paths, in_place, args.quiet)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let errors = formatted_paths
|
let errors = formatted_paths
|
||||||
|
@ -382,9 +382,11 @@ pub fn main() -> std::io::Result<()> {
|
||||||
|
|
||||||
let changed = formatted_paths
|
let changed = formatted_paths
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|formatted_path| match formatted_path.status {
|
.filter(|formatted_path| {
|
||||||
alejandra::format::Status::Changed(changed) => changed,
|
match formatted_path.status {
|
||||||
_ => false,
|
alejandra::format::Status::Changed(changed) => changed,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue