From 04f7cf535992f05ea56c701f25a6adad564796ae Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 16 Feb 2020 00:18:50 +0100 Subject: Allow dot in project name --- src/Conf.cpp | 2 +- src/main.cpp | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Conf.cpp b/src/Conf.cpp index e3c894a..eb66b6d 100644 --- a/src/Conf.cpp +++ b/src/Conf.cpp @@ -637,7 +637,7 @@ namespace sibs for(int i = 0; i < projectName.size(); ++i) { char c = projectName[i]; - if(!isalpha(c) && !isdigit(c) && c != '-' && c != '_') + if(!isalpha(c) && !isdigit(c) && c != '-' && c != '_' && c != '.') return false; } diff --git a/src/main.cpp b/src/main.cpp index 5efafe6..af43892 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -793,6 +793,15 @@ static void gitIgnoreAppendSibs(const FileString &gitIgnoreFilePath) ferr << "Failed to add sibs to .gitignore, reason: " << toFileString(result.getErrMsg()) << endl; } +static void validateProjectName(const std::string &projectName) +{ + if(!isProjectNameValid(projectName)) + { + ferr << "Project name can only contain alphanumerical characters, dash (-), underscore (_), dot (.) and has to be at least 1 character long" << endl; + exit(20); + } +} + static int initProject(int argc, const _tinydir_char_t **argv) { FileString projectPath; @@ -939,11 +948,7 @@ static int initProject(int argc, const _tinydir_char_t **argv) else projectName = toUtf8(projectPath); - if(!isProjectNameValid(projectName)) - { - ferr << "Project name can only contain alphanumerical characters, dash (-) or underscore (_) and has to be longer than 0 characters" << endl; - exit(20); - } + validateProjectName(projectName); auto createProjectConfResult = newProjectCreateConf(projectName, projectTypeConf, projectPath); if(!createProjectConfResult) @@ -1320,11 +1325,7 @@ static int newProject(int argc, const _tinydir_char_t **argv) exit(20); } - if(!isProjectNameValid(projectName)) - { - ferr << "Project name can only contain alphanumerical characters, dash (-) or underscore (_)" << endl; - exit(20); - } + validateProjectName(projectName); FileString projectPath = cwdResult.unwrap(); projectPath += TINYDIR_STRING("/"); -- cgit v1.2.3