Skip to content

Commit 2b90498

Browse files
committed
refactor: move config reading into own function
1 parent acd4dda commit 2b90498

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

src/cli/command.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::marker::PhantomData;
22

33
use clap::{Parser, Subcommand as ClapSubcommand};
4-
use lum_log::error;
54
use thiserror::Error;
65

76
use crate::{

src/main.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::fs::{self, File};
44
use dnrs::{Config, RuntimeError, run, setup_logger};
55
use lum_config::{ConfigPathError, EnvironmentConfigParseError, FileConfigParseError, merge};
66
use lum_log::info;
7-
use lum_log::{error, log::SetLoggerError};
7+
use lum_log::log::SetLoggerError;
88
use thiserror::Error;
99

1010
/*
@@ -72,10 +72,7 @@ impl Debug for Error {
7272
}
7373
}
7474

75-
#[tokio::main]
76-
async fn main() -> Result<(), Error> {
77-
setup_logger()?;
78-
75+
fn read_config() -> Result<Config, Error> {
7976
let config_path = dirs::config_dir()
8077
.ok_or(Error::NoConfigDirectory)?
8178
.join(APP_NAME)
@@ -104,7 +101,16 @@ async fn main() -> Result<(), Error> {
104101
info!("Created default config file at: {}", config_path.display());
105102
}
106103

104+
Ok(config)
105+
}
106+
107+
#[tokio::main]
108+
async fn main() -> Result<(), Error> {
109+
setup_logger()?;
110+
111+
let config = read_config()?;
107112
run(config).await?;
113+
108114
Ok(())
109115
}
110116

0 commit comments

Comments
 (0)