Skip to content

Commit

Permalink
Add directory flag to set which directory to read assests from
Browse files Browse the repository at this point in the history
  • Loading branch information
ollej committed Feb 12, 2022
1 parent 984bb15 commit b96d908
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions src/main.rs
Expand Up @@ -13,21 +13,14 @@ use rusty_slider::prelude::*;
about = "A small tool to display markdown files as a slideshow."
)]
struct CliOptions {
/// Path to directory to load files from
#[structopt(short, long, parse(from_os_str), default_value = "assets")]
pub directory: PathBuf,
/// Markdown files with slides text.
#[structopt(
short,
long,
parse(from_os_str),
default_value = "assets/rusty-slider.md"
)]
#[structopt(short, long, parse(from_os_str), default_value = "rusty-slider.md")]
pub slides: PathBuf,
/// File with theme options.
#[structopt(
short,
long,
parse(from_os_str),
default_value = "assets/default-theme.json"
)]
#[structopt(short, long, parse(from_os_str), default_value = "default-theme.json")]
pub theme: PathBuf,
/// Automatically switch slides every N seconds.
#[structopt(short, long, default_value = "0")]
Expand All @@ -40,6 +33,20 @@ struct CliOptions {
pub enable_code_execution: bool,
}

impl CliOptions {
fn slides_path(&self) -> PathBuf {
let mut path = self.directory.clone();
path.push(self.slides.clone());
path
}

fn theme_path(&self) -> PathBuf {
let mut path = self.directory.clone();
path.push(self.theme.clone());
path
}
}

fn window_conf() -> Conf {
Conf {
window_title: "Rusty Slider".to_owned(),
Expand All @@ -52,13 +59,13 @@ fn window_conf() -> Conf {
async fn main() {
let opt = CliOptions::from_iter(get_program_parameters().iter());

let theme = Theme::load(opt.theme).await;
let theme = Theme::load(opt.theme_path()).await;
debug!(
"background_color: {:?} text_color: {:?} heading_color{:?}",
theme.background_color, theme.text_color, theme.heading_color,
);
let mut shader_activated = theme.shader;
let mut slides = Slides::load(opt.slides, theme, opt.automatic).await;
let mut slides = Slides::load(opt.slides_path(), theme, opt.automatic).await;

let render_target = render_target(screen_width() as u32, screen_height() as u32);
render_target.texture.set_filter(FilterMode::Linear);
Expand Down

0 comments on commit b96d908

Please sign in to comment.