Skip to content

Commit

Permalink
lowercase warnings, --just insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson committed Nov 21, 2023
1 parent 6f3a8ed commit fbfbb02
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
19 changes: 19 additions & 0 deletions bin/src/addons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,25 @@ impl Addon {
for location in [Location::Addons, Location::Optionals] {
addons.extend(location.scan()?);
}
for addon in &addons {
if addon.name().to_lowercase() != addon.name() {
warn!(
"Addon name {} is not lowercase, it is highly recommended to use lowercase names",
addon.name()
);
}
if addons.iter().any(|a| {
a.name().to_lowercase() == addon.name().to_lowercase() && a.name() != addon.name()
}) {
return Err(Error::AddonNameDuplicate(addon.name().to_string()));
}
if addons.iter().any(|a| {
a.name().to_lowercase() == addon.name().to_lowercase()
&& a.location() != addon.location()
}) {
return Err(Error::AddonDuplicate(addon.name().to_string()));
}
}
Ok(addons)
}
}
Expand Down
4 changes: 2 additions & 2 deletions bin/src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub fn pre_execute(matches: &ArgMatches) -> Result<(), Error> {
let just = matches
.get_many::<String>("just")
.unwrap_or_default()
.map(std::string::String::as_str)
.map(|s| s.to_lowercase())
.collect::<Vec<_>>();
let mut ctx = Context::new(
std::env::current_dir()?,
Expand All @@ -65,7 +65,7 @@ pub fn pre_execute(matches: &ArgMatches) -> Result<(), Error> {
},
)?;
if !just.is_empty() {
ctx = ctx.filter(|a, _| just.contains(&a.name()));
ctx = ctx.filter(|a, _| just.contains(&a.name().to_lowercase()));
}
let mut executor = Executor::new(&ctx);

Expand Down
4 changes: 2 additions & 2 deletions bin/src/commands/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub fn execute(matches: &ArgMatches, launch_optionals: &[String]) -> Result<Cont
let just = matches
.get_many::<String>("just")
.unwrap_or_default()
.map(std::string::String::as_str)
.map(|s| s.to_lowercase())
.collect::<Vec<_>>();

let ctx = Context::new(
Expand All @@ -73,7 +73,7 @@ pub fn execute(matches: &ArgMatches, launch_optionals: &[String]) -> Result<Cont
},
)?
.filter(|a, config| {
if !just.is_empty() && !just.contains(&a.name()) {
if !just.is_empty() && !just.contains(&a.name().to_lowercase()) {
return false;
}
if launch_optionals.iter().any(|o| o == a.name()) {
Expand Down
4 changes: 4 additions & 0 deletions bin/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ pub enum Error {
#[error("New can only be ran in an interactive terminal")]
NewNoInput,

#[error("Addon duplicated with different case: {0}")]
AddonNameDuplicate(String),
#[error("Addon present in addons and optionals: {0}")]
AddonDuplicate(String),
#[error("Invalid addon location: {0}")]
AddonLocationInvalid(String),
#[error("Optional addon not found: {0}")]
Expand Down

0 comments on commit fbfbb02

Please sign in to comment.