mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Create simple main.c3 by init command
This commit is contained in:
committed by
Christoffer Lerno
parent
da1a45f718
commit
2fefed5bda
@@ -185,6 +185,16 @@ const char* JSON_DYNAMIC =
|
||||
" */\n"
|
||||
"}";
|
||||
|
||||
const char* MAIN_TEMPLATE =
|
||||
"module %s;\n"
|
||||
"import std::io;\n"
|
||||
"\n"
|
||||
"fn int main(char[][] args)\n"
|
||||
"{\n"
|
||||
"\tio::println(\"Hello, World!\");\n"
|
||||
"\treturn 0;\n"
|
||||
"}\n";
|
||||
|
||||
void create_project(BuildOptions *build_options)
|
||||
{
|
||||
const char *template;
|
||||
@@ -252,7 +262,10 @@ void create_project(BuildOptions *build_options)
|
||||
|
||||
if (!dir_change("src")) goto ERROR;
|
||||
|
||||
if (!file_touch("main.c3")) goto ERROR;
|
||||
file = fopen("main.c3", "w");
|
||||
if (!file) goto ERROR;
|
||||
(void) fprintf(file, MAIN_TEMPLATE, build_options->project_name);
|
||||
if (fclose(file)) goto ERROR;
|
||||
|
||||
if (!dir_change("..")) goto ERROR;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user