Merge pull request #1122 from NotSpooky/master
Ask the user again in init when the name given isn't valid
commit d3103c2324f6adbd6a9cf35c9e879d7a7026d7c2
2 parents 77fd257 + cc2ae63
@Sönke Ludwig Sönke Ludwig authored on 14 May 2017
GitHub committed on 14 May 2017
Showing 1 changed file
View
24
source/dub/commandline.d
logError("Invalid format, \""~rawfmt~"\", enter either \"sdl\" or \"json\".");
}
}
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);
p.copyright = input("Copyright string", p.copyright);