diff --git a/source/dub/commandline.d b/source/dub/commandline.d index 08830c7..5ab4bb8 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -491,7 +491,18 @@ } } auto author = p.authors.join(", "); - p.name = input("Name", p.name); + while (true) { + // Tries getting the name until a valid one is given. + import std.regex; + auto nameRegex = regex(`^[a-z\-_]+$`); + string triedName = input("Name", p.name); + if (triedName.matchFirst(nameRegex).empty) { + logError("Invalid name, \""~triedName~"\", names should consist only of lowercase alphanumeric characters, - and _."); + } else { + p.name = triedName; + break; + } + } p.description = input("Description", p.description); p.authors = input("Author name", author).split(",").map!(a => a.strip).array; p.license = input("License", p.license);