Skip to content

Commit

Permalink
refactor: add DEFAULT_CONFIG const
Browse files Browse the repository at this point in the history
  • Loading branch information
InioX committed Aug 15, 2023
1 parent c567970 commit af59a63
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/util/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ pub struct ConfigFile {
const ERROR_TEXT: &str =
"Error reading config file, check https://github.com/InioX/Matugen#configuration for help";

const DEFAULT_CONFIG: &str = r#"
[config]
[templates]
"#;

impl ConfigFile {
pub fn read(args: &Cli) -> Result<ConfigFile, Report> {
match &args.config {
Expand Down Expand Up @@ -90,12 +95,6 @@ impl ConfigFile {
}

fn read_from_fallback_path() -> Result<ConfigFile, Report> {
let content: String = String::from(
r#"
[config]
[templates]
"#,
);
Ok(toml::from_str(&content)?)
Ok(toml::from_str(&DEFAULT_CONFIG)?)
}
}

0 comments on commit af59a63

Please sign in to comment.