Skip to content

Commit

Permalink
Removes unused (and unupdated) global version value, cleans up expect…
Browse files Browse the repository at this point in the history
…ations around the "templates" folder (#12)

This is technically a breaking change but like.... no it isn't.
Re:templates, we do assume a default templates folder but we don't
really make that assumption clear, which is a bad pattern
  • Loading branch information
LemonInTheDark authored Aug 30, 2024
1 parent 495405b commit d03f857
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hypnagogic_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct Args {
#[arg(short, long)]
output: Option<String>,
/// Location of the templates folder
#[arg(short, long, default_value_t = String::from("templates"))]
#[arg(short, long, default_value_t = String::from(hypnagogic_core::config::DEFAULT_TEMPLATE_LOCATION))]
templates: String,
/// List of space separated output directory/file(s)
#[arg(num_args = 1.., value_delimiter = ' ', required = true)]
Expand Down
2 changes: 1 addition & 1 deletion hypnagogic_core/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub mod blocks;
pub mod error;
pub mod template_resolver;

pub const LATEST_VERSION: &str = "1";
pub const DEFAULT_TEMPLATE_LOCATION: &str = "templates";

#[tracing::instrument(skip(resolver, input))]
pub fn read_config<R: Read + Seek>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use tracing::{debug, trace};

use crate::config::template_resolver::error::{TemplateError, TemplateResult};
use crate::config::template_resolver::TemplateResolver;
use crate::config::DEFAULT_TEMPLATE_LOCATION;

/// Loads templates from a folder on the filesystem.
#[derive(Clone, PartialEq, Eq, Debug)]
Expand All @@ -28,7 +29,8 @@ impl FileResolver {

impl Default for FileResolver {
fn default() -> Self {
FileResolver::new(Path::new("templates")).expect("templates folder does not exist")
FileResolver::new(Path::new(DEFAULT_TEMPLATE_LOCATION))
.unwrap_or_else(|_| panic!("{DEFAULT_TEMPLATE_LOCATION} folder does not exist"))
}
}

Expand Down

0 comments on commit d03f857

Please sign in to comment.