File tree Expand file tree Collapse file tree
include/vix/cli/commands/make Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515#define VIX_MAKE_OPTIONS_HPP
1616
1717#include < string>
18+ #include < vector>
1819
1920namespace vix ::cli::make
2021{
22+ struct MakeFieldOption
23+ {
24+ std::string name;
25+ std::string type;
26+ };
27+
28+ struct MakeClassOptions
29+ {
30+ std::vector<MakeFieldOption> fields;
31+
32+ bool interactive = false ;
33+ bool with_default_ctor = true ;
34+ bool with_value_ctor = true ;
35+ bool with_getters_setters = true ;
36+ bool with_copy_move = true ;
37+ bool with_virtual_destructor = true ;
38+ };
39+
2140 struct MakeOptions
2241 {
2342 std::string kind;
@@ -31,7 +50,9 @@ namespace vix::cli::make
3150 bool print_only = false ;
3251 bool header_only = false ;
3352 bool show_help = false ;
53+
54+ MakeClassOptions class_options;
3455 };
35- }
56+ } // namespace vix::cli::make
3657
3758#endif
Original file line number Diff line number Diff line change 1717#include < vix/cli/commands/make/MakeDispatcher.hpp>
1818#include < vix/cli/commands/make/MakeResult.hpp>
1919
20+ #include < string>
21+ #include < vector>
22+
2023namespace vix ::cli::make::generators
2124{
25+ struct ClassField
26+ {
27+ std::string name;
28+ std::string type;
29+ };
30+
31+ struct ClassSpec
32+ {
33+ std::string name;
34+ std::string name_space;
35+ std::vector<ClassField> fields;
36+
37+ bool header_only{false };
38+ bool with_default_ctor{true };
39+ bool with_value_ctor{true };
40+ bool with_getters_setters{true };
41+ bool with_copy_move{true };
42+ bool with_virtual_destructor{true };
43+ };
44+
2245 [[nodiscard]] MakeResult generate_class (const MakeContext &ctx);
23- }
46+
47+ [[nodiscard]] MakeResult generate_class (const MakeContext &ctx,
48+ const ClassSpec &spec);
49+ } // namespace vix::cli::make::generators
2450
2551#endif
Original file line number Diff line number Diff line change @@ -324,22 +324,52 @@ namespace vix::cli::dispatch
324324
325325 bool Dispatcher::has (const std::string &cmd) const
326326 {
327+ if (cmd.size () > 5 && cmd.rfind (" make:" , 0 ) == 0 )
328+ return map_.find (" make" ) != map_.end ();
329+
327330 return map_.find (cmd) != map_.end ();
328331 }
329332
330333 int Dispatcher::run (const std::string &cmd, const Args &args) const
331334 {
335+ if (cmd.size () > 5 && cmd.rfind (" make:" , 0 ) == 0 )
336+ {
337+ auto it = map_.find (" make" );
338+ if (it == map_.end ())
339+ return 127 ;
340+
341+ Args forwarded_args;
342+ forwarded_args.reserve (args.size () + 1 );
343+ forwarded_args.push_back (cmd.substr (5 ));
344+
345+ for (const auto &arg : args)
346+ forwarded_args.push_back (arg);
347+
348+ return it->second .run (forwarded_args);
349+ }
350+
332351 auto it = map_.find (cmd);
333352 if (it == map_.end ())
334353 return 127 ;
354+
335355 return it->second .run (args);
336356 }
337357
338358 int Dispatcher::help (const std::string &cmd) const
339359 {
360+ if (cmd.size () > 5 && cmd.rfind (" make:" , 0 ) == 0 )
361+ {
362+ auto it = map_.find (" make" );
363+ if (it == map_.end ())
364+ return 127 ;
365+
366+ return it->second .help ();
367+ }
368+
340369 auto it = map_.find (cmd);
341370 if (it == map_.end ())
342371 return 127 ;
372+
343373 return it->second .help ();
344374 }
345375
You can’t perform that action at this time.
0 commit comments