Skip to content

Commit f964953

Browse files
committed
cli(new): generate per-project config/config.json for apps
1 parent a7462cf commit f964953

1 file changed

Lines changed: 35 additions & 3 deletions

File tree

src/commands/NewCommand.cpp

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,35 @@ int main()
9090
}
9191
)";
9292

93+
constexpr const char *kAppConfigJson = R"JSON({
94+
"server": {
95+
"port": 8080,
96+
"request_timeout": 2000,
97+
"io_threads": 0,
98+
"session_timeout_sec": 20
99+
},
100+
"logging": {
101+
"async": true,
102+
"queue_max": 20000,
103+
"drop_on_overflow": true
104+
},
105+
"waf": {
106+
"mode": "basic",
107+
"max_target_len": 4096,
108+
"max_body_bytes": 1048576
109+
},
110+
"database": {
111+
"default": {
112+
"host": "localhost",
113+
"user": "root",
114+
"password": "",
115+
"name": "",
116+
"port": 3306
117+
}
118+
}
119+
}
120+
)JSON";
121+
93122
static std::string make_lib_header(const std::string &name)
94123
{
95124
std::string s;
@@ -1209,10 +1238,7 @@ int main()
12091238
return f;
12101239
}
12111240

1212-
// ==========================================================
12131241
// Generation routines
1214-
// ==========================================================
1215-
12161242
static bool generate_app_project(
12171243
const fs::path &projectDir,
12181244
const std::string &projName,
@@ -1221,17 +1247,23 @@ int main()
12211247
{
12221248
const fs::path srcDir = projectDir / "src";
12231249
const fs::path testsDir = projectDir / "tests";
1250+
const fs::path configDir = projectDir / "config";
12241251

12251252
if (!ensure_dir(srcDir, err))
12261253
return false;
12271254
if (!ensure_dir(testsDir, err))
12281255
return false;
1256+
if (!ensure_dir(configDir, err))
1257+
return false;
12291258

12301259
if (!write_text_file(srcDir / "main.cpp", kMainCpp, err))
12311260
return false;
12321261
if (!write_text_file(testsDir / "test_basic.cpp", kBasicTestCpp_App, err))
12331262
return false;
12341263

1264+
if (!write_text_file(configDir / "config.json", kAppConfigJson, err))
1265+
return false;
1266+
12351267
if (!write_text_file(projectDir / "CMakeLists.txt", make_cmakelists_app(projName, features), err))
12361268
return false;
12371269
if (!write_text_file(projectDir / "README.md", make_readme_app(projName), err))

0 commit comments

Comments
 (0)