forked from katzen-cafe/iowo
app(doc): well... write the docs
This commit is contained in:
parent
6006f92d9c
commit
0615ea653c
5 changed files with 25 additions and 6 deletions
|
@ -14,6 +14,7 @@ pub struct Config {
|
|||
}
|
||||
|
||||
impl Config {
|
||||
/// Get the configs from all possible places (args, file, env...)
|
||||
pub fn read() -> Self {
|
||||
let args = Args::parse();
|
||||
let config_path = if let Some(config_path) = args.config_path {
|
||||
|
@ -22,6 +23,7 @@ impl Config {
|
|||
find_config_file()
|
||||
};
|
||||
|
||||
// try to read a maybe existing config file
|
||||
let file_config = if let Ok(config_path) = config_path {
|
||||
let file_config = Configs::read(config_path);
|
||||
|
||||
|
@ -52,13 +54,22 @@ impl Config {
|
|||
}
|
||||
|
||||
pub mod error {
|
||||
/// Errors that can occur when reading configs
|
||||
#[derive(Debug)]
|
||||
pub enum ConfigError {
|
||||
/// The config dir doesn't exist
|
||||
NoConfigDir,
|
||||
/// We didn't find a config file in the config dir
|
||||
NoConfigFileFound,
|
||||
/// An io error happened while reading/opening it!
|
||||
IoError(std::io::Error),
|
||||
/// The given extension (via an argument) isn't known.
|
||||
///
|
||||
/// Occurs if the extension is neither `.json` nor `.ron` (including if there is no extension, in which case this will be `None`).
|
||||
UnknownExtension(Option<String>),
|
||||
/// Wrapper around an `Error` from `serde_json`
|
||||
SerdeJsonError(serde_json::Error),
|
||||
/// Wrapper around a `SpannedError` from `ron`
|
||||
SerdeRonError(ron::error::SpannedError),
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue