@@ -99,7 +99,7 @@ namespace vix::commands::NewCommand
9999 if (argsIn.empty ())
100100 {
101101 error (" Missing project name." );
102- hint (" Usage: vix new <name|path> [-d|--dir <base_dir>] [--app|--lib] [--force]" );
102+ hint (" Usage: vix new <name|path> [-d|--dir <base_dir>] [--app|--lib|--game ] [--force]" );
103103 return 1 ;
104104 }
105105
@@ -112,47 +112,63 @@ namespace vix::commands::NewCommand
112112
113113 const bool wantsLib = has_any (args, {" --lib" , " --library" , " --type=lib" , " --type=library" });
114114 const bool wantsApp = has_any (args, {" --app" , " --application" , " --type=app" , " --type=application" });
115+ const bool wantsGame = has_any (args, {" --game" , " --type=game" });
115116
116117 for (const auto &f : {" --lib" , " --library" , " --type=lib" , " --type=library" ,
117- " --app" , " --application" , " --type=app" , " --type=application" })
118+ " --app" , " --application" , " --type=app" , " --type=application" ,
119+ " --game" , " --type=game" })
118120 consume_flag (args, f);
119121
120122 if (args.empty ())
121123 {
122124 error (" Missing project name." );
123- hint (" Usage: vix new <name|path> [--template vue] [--app|--lib] [--force]" );
125+ hint (" Usage: vix new <name|path> [--template vue|game ] [--app|--lib|--game ] [--force]" );
124126 return 1 ;
125127 }
126128
127- if (!args[ 0 ]. empty () && args[ 0 ][ 0 ] == ' - ' && ! gen::is_dot_path (args[ 0 ] ))
129+ if ((wantsLib && wantsApp) || (wantsLib && wantsGame) || (wantsApp && wantsGame ))
128130 {
129- error (" Missing project name." );
130- hint (" Options must come after a project name or be followed by one." );
131- step (" vix new my-app --template vue" );
131+ error (" Conflicting options: choose only one project type." );
132132 return 1 ;
133133 }
134134
135- if (wantsLib && wantsApp )
135+ if (!args[ 0 ]. empty () && args[ 0 ][ 0 ] == ' - ' && ! gen::is_dot_path (args[ 0 ]) )
136136 {
137- error (" Conflicting options: choose either --app or --lib." );
137+ error (" Missing project name." );
138+ hint (" Options must come after a project name or be followed by one." );
139+ step (" vix new my-app --template vue" );
138140 return 1 ;
139141 }
140142
141143 if (templateOpt.has_value ())
142144 {
143145 const std::string tpl = *templateOpt;
144146
145- if (tpl != " vue" )
147+ if (tpl != " vue" && tpl != " game " )
146148 {
147149 error (" Unknown template: " + tpl);
148- hint (" Supported templates: vue" );
150+ hint (" Supported templates: vue, game " );
149151 return 1 ;
150152 }
151153
152154 if (wantsLib)
153155 {
154- error (" Conflicting options: --template vue cannot be used with --lib." );
155- hint (" Vue templates generate applications." );
156+ error (" Conflicting options: --template cannot be used with --lib." );
157+ hint (" Templates currently supported: vue, game." );
158+ return 1 ;
159+ }
160+
161+ if (wantsApp && *templateOpt == " game" )
162+ {
163+ error (" Conflicting options: --template game cannot be used with --app." );
164+ hint (" Use --game or --template game." );
165+ return 1 ;
166+ }
167+
168+ if (wantsGame && *templateOpt == " vue" )
169+ {
170+ error (" Conflicting options: --template vue cannot be used with --game." );
171+ hint (" Use --app, --template vue, or --template game." );
156172 return 1 ;
157173 }
158174 }
@@ -277,10 +293,18 @@ namespace vix::commands::NewCommand
277293 // ------------------------------------------------------------------
278294 TemplateKind kind = TemplateKind::App;
279295
280- if (templateOpt.has_value () && *templateOpt == " vue" )
296+ if (templateOpt.has_value () && *templateOpt == " game" )
297+ {
298+ kind = TemplateKind::Game;
299+ }
300+ else if (templateOpt.has_value () && *templateOpt == " vue" )
281301 {
282302 kind = TemplateKind::Vue;
283303 }
304+ else if (wantsGame)
305+ {
306+ kind = TemplateKind::Game;
307+ }
284308 else if (wantsLib)
285309 {
286310 kind = TemplateKind::Lib;
@@ -353,6 +377,21 @@ namespace vix::commands::NewCommand
353377 return 0 ;
354378 }
355379
380+ if (kind == TemplateKind::Game)
381+ {
382+ if (!gen::generate_game_project (projectDir, projName, genErr))
383+ {
384+ vix::cli::util::err_line (std::cerr, " Failed to create project files." );
385+ vix::cli::util::warn_line (std::cerr, genErr);
386+ return 1 ;
387+ }
388+
389+ vix::cli::util::ok_line (std::cout, " Project created." );
390+ vix::cli::util::kv (std::cout, " Location" , projectDir.string ());
391+ gen::print_next_steps_game (projectDir, projName);
392+ return 0 ;
393+ }
394+
356395 if (kind == TemplateKind::App)
357396 {
358397 if (!gen::generate_app_project (projectDir, projName, features, genErr))
@@ -401,7 +440,9 @@ namespace vix::commands::NewCommand
401440 << " vix new api\n "
402441 << " vix new .\n "
403442 << " vix new tree --lib\n "
443+ << " vix new mario --game\n "
404444 << " vix new shop --template vue\n "
445+ << " vix new platformer --template game\n "
405446 << " vix new blog -d ./projects\n "
406447 << " vix new api --force\n\n "
407448
@@ -411,12 +452,12 @@ namespace vix::commands::NewCommand
411452 << " • Creates a vix.json manifest\n "
412453 << " • For apps, creates an executable target matching the project name\n "
413454 << " • For libraries, creates a header-only CMake interface target\n "
414- << " • Applies the selected template (app or library)\n\n "
455+ << " • Applies the selected template (app, game, library, or Vue )\n\n "
415456
416- << " Options\n "
417457 << " --app Generate an application (default)\n "
458+ << " --game Generate a Vix game project\n "
418459 << " --lib Generate a header-only library\n "
419- << " --template Project template, currently: vue\n "
460+ << " --template Project template, currently: vue, game \n "
420461 << " -d, --dir Base directory for project creation\n "
421462 << " --force Overwrite existing directory\n\n "
422463
@@ -425,6 +466,11 @@ namespace vix::commands::NewCommand
425466 << " vix build\n "
426467 << " vix run\n\n "
427468
469+ << " Game workflow\n "
470+ << " cd mario/\n "
471+ << " vix build\n "
472+ << " vix run\n\n "
473+
428474 << " Library workflow\n "
429475 << " cd tree/\n "
430476 << " vix build --build-target all\n "
0 commit comments