mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-22 09:01:04 -05:00
refactor: Re-order main
This commit is contained in:
parent
5cfe913d03
commit
94ee49b068
1 changed files with 24 additions and 24 deletions
48
src/main.rs
48
src/main.rs
|
@ -12,27 +12,9 @@ mod checks;
|
|||
mod config;
|
||||
mod dict;
|
||||
|
||||
fn init_logging(level: Option<log::Level>) {
|
||||
if let Some(level) = level {
|
||||
let mut builder = env_logger::Builder::new();
|
||||
|
||||
builder.filter(None, level.to_level_filter());
|
||||
|
||||
if level == log::LevelFilter::Trace {
|
||||
builder.format_timestamp_secs();
|
||||
} else {
|
||||
builder.format(|f, record| {
|
||||
writeln!(
|
||||
f,
|
||||
"[{}] {}",
|
||||
record.level().to_string().to_lowercase(),
|
||||
record.args()
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
builder.init();
|
||||
}
|
||||
fn main() {
|
||||
let code = run().unwrap();
|
||||
std::process::exit(code);
|
||||
}
|
||||
|
||||
fn run() -> Result<i32, anyhow::Error> {
|
||||
|
@ -178,7 +160,25 @@ fn run() -> Result<i32, anyhow::Error> {
|
|||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let code = run().unwrap();
|
||||
std::process::exit(code);
|
||||
fn init_logging(level: Option<log::Level>) {
|
||||
if let Some(level) = level {
|
||||
let mut builder = env_logger::Builder::new();
|
||||
|
||||
builder.filter(None, level.to_level_filter());
|
||||
|
||||
if level == log::LevelFilter::Trace {
|
||||
builder.format_timestamp_secs();
|
||||
} else {
|
||||
builder.format(|f, record| {
|
||||
writeln!(
|
||||
f,
|
||||
"[{}] {}",
|
||||
record.level().to_string().to_lowercase(),
|
||||
record.args()
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
builder.init();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue