aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2017-12-31 09:13:32 +0100
committerdec05eba <dec05eba@protonmail.com>2017-12-31 09:29:38 +0100
commiteda6a8e2c66380c773db32f720ef4b6a89f9b50a (patch)
tree6d8f5f9a6dd2d1923864f94d0df2db85d041d2d4 /src/main.cpp
parentc849a30e7e9e2e7608376c9c538e1b45e623c805 (diff)
Update new project template with user platform
Validate package name only contains safe characters. TODO: Validate package name is allowed on windows, names such as NUL, AUX are not allowed
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 88a837f..fc413d4 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -314,7 +314,11 @@ void newProjectCreateConf(const string &projectName, const string &projectType,
string projectConfStr = "[package]\n";
projectConfStr += "name = \"" + projectName + "\"\n";
projectConfStr += "type = \"" + projectType + "\"\n";
- projectConfStr += "version = \"0.1.0\"\n\n";
+ projectConfStr += "version = \"0.1.0\"\n";
+ projectConfStr += "platforms = [\"";
+ projectConfStr += asString(SYSTEM_PLATFORM);
+ projectConfStr += "\"]\n";
+ projectConfStr += "\n";
projectConfStr += "[dependencies]\n";
FileString projectConfPath = projectPath;
@@ -353,6 +357,12 @@ int newProject(int argc, const _tinydir_char_t **argv)
}
string projectName = toUtf8(argv[0]);
+ if(!isProjectNameValid(projectName))
+ {
+ ferr << "Project name can only contain alphanumerical characters, dash (-) or underscore (_)" << endl;
+ exit(20);
+ }
+
FileString projectPath = cwdResult.unwrap();
projectPath += TINYDIR_STRING("/");
projectPath += toFileString(projectName);
@@ -382,7 +392,7 @@ int newProject(int argc, const _tinydir_char_t **argv)
newProjectCreateConf(projectName, projectTypeConf, projectPath);
createProjectSubDir(projectPath + TINYDIR_STRING("/src"));
createProjectSubDir(projectPath + TINYDIR_STRING("/include"));
- createProjectFile(projectPath + TINYDIR_STRING("/src/main.cpp"), "#include <cstdio>\n\nint main()\n{\n return 0;\n}\n");
+ createProjectFile(projectPath + TINYDIR_STRING("/src/main.cpp"), "#include <cstdio>\n\nint main()\n{\n printf(\"hello, world!\\n\");\n return 0;\n}\n");
// We are ignoring git init result on purpose. If it fails, just ignore it; not important
gitInitProject(projectPath);
return 0;