diff options
Diffstat (limited to 'src/context.rs')
-rw-r--r-- | src/context.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/context.rs b/src/context.rs index 6bc4c05..55f3f97 100644 --- a/src/context.rs +++ b/src/context.rs @@ -14,6 +14,15 @@ pub struct Options { pub config: Option<PathBuf>, #[structopt(help = "Picture location")] pub load: PathBuf, + #[structopt(short, long, default_value = "png", help = "Image extension to use for converted files")] + pub ext: String, + #[structopt(long, short, default_value = "build", help = "Where to build site")] + pub builddir: PathBuf, + + #[structopt(long, default_value = "1080", help = "Scaled size for image")] + pub size_scaled: u32, + #[structopt(long, default_value = "720", help = "Thumbnail size for image")] + pub size_thumb: u32, } #[derive(Debug)] @@ -36,16 +45,26 @@ pub struct Config { pub struct Context { pub options: Options, pub config: Config, + pub imgdir: PathBuf, } impl Context { pub fn new_with_args() -> Result<Context, ConfigError> { let opts = Options::from_args(); let config = Config::load_with_options(&opts)?; + let imgdir = opts.builddir.join("imgs"); + + // Create img dir + if let Err(err) = fs::create_dir(&imgdir) { + if err.kind() != io::ErrorKind::AlreadyExists { + return Err(ConfigError::from(err)); + } + } Ok(Context { options: opts, config: config, + imgdir: imgdir, }) } |