Skip to content

Commit

Permalink
refac
Browse files Browse the repository at this point in the history
  • Loading branch information
splurf committed Jun 11, 2024
1 parent e7ff14b commit 4f13c12
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/base/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ fn get_frames_from_path(
}

pub fn get_frames(cfg: &Config) -> Result<Vec<AsciiFrame>> {
if let Some(path) = cfg.images() {
get_frames_from_path(path, cfg.fps(), cfg.is_colored())
if let Some(path) = cfg.gif() {
get_frames_from_path(path, cfg.fps(), cfg.colored())
} else {
Ok(donut::get_frames())
}
Expand Down
17 changes: 10 additions & 7 deletions src/base/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,21 @@ pub struct Config {
#[arg(short, long, default_value_t = 8080)]
port: u16,

/// Location path
/// URI location path
#[arg(long, default_value_t = String::from('/'), value_parser = parse_path)]
path: String,

/// Custom provided GIF
#[arg(short, long)]
images: Option<PathBuf>,
gif: Option<PathBuf>,

/// Custom Frames/sec
#[arg(short, long)]
fps: Option<f32>,

/// Enable/Disable color
#[arg(short, long)]
is_colored: bool,
colored: bool,
}

impl Config {
Expand All @@ -59,16 +62,16 @@ impl Config {
}

/// Return the path to the images.
pub fn images(&self) -> Option<&Path> {
self.images.as_deref()
pub fn gif(&self) -> Option<&Path> {
self.gif.as_deref()
}

/// Return the frames/second, if specified.
pub const fn fps(&self) -> Option<f32> {
self.fps
}

pub const fn is_colored(&self) -> bool {
self.is_colored
pub const fn colored(&self) -> bool {
self.colored
}
}

0 comments on commit 4f13c12

Please sign in to comment.