-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
74 additions
and
11 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
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,28 @@ | ||
use std::{io, path::PathBuf}; | ||
|
||
use mc_repack_core::min; | ||
use crate::Result_; | ||
|
||
#[derive(serde::Deserialize)] | ||
pub struct Config { | ||
pub json: Option<min::json::JSONConfig>, | ||
pub nbt: Option<min::nbt::NBTConfig>, | ||
pub png: Option<min::png::PNGConfig>, | ||
pub toml: Option<min::toml::TOMLConfig> | ||
} | ||
|
||
pub fn read_config(path: Option<PathBuf>) -> Result_<Config> { | ||
let path = match path { | ||
Some(p) => { | ||
let meta = std::fs::metadata(&p)?; | ||
if meta.is_dir() { | ||
p.join("mc-repack.toml") | ||
} else { | ||
p | ||
} | ||
} | ||
None => PathBuf::from("mc-repack.toml") | ||
}; | ||
let f = std::fs::read_to_string(path)?; | ||
toml::from_str(&f).map_err(io::Error::other) | ||
} |
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