-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #362 from hannobraun/config
Add configuration file
- Loading branch information
Showing
7 changed files
with
135 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# The default path that models are loaded from. If the `--model` argument is a | ||
# relative path, it is assumed to be relative to `default_path`. | ||
default_path = "models" | ||
|
||
# The default models that is loaded, if none is specified. If this is a relative | ||
# path, it should be relative to `default_path`. | ||
default_model = "star" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use std::path::PathBuf; | ||
|
||
use anyhow::Context as _; | ||
use figment::{ | ||
providers::{Env, Format as _, Toml}, | ||
Figment, | ||
}; | ||
use serde::Deserialize; | ||
|
||
#[derive(Debug, Deserialize)] | ||
pub struct Config { | ||
pub default_path: PathBuf, | ||
pub default_model: PathBuf, | ||
} | ||
|
||
impl Config { | ||
pub fn load() -> Result<Self, anyhow::Error> { | ||
Figment::new() | ||
.merge(Toml::file("fj.toml")) | ||
.merge(Env::prefixed("FJ_")) | ||
.extract() | ||
.context("Error loading configuration") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters