Skip to content

Commit 8830918

Browse files
committed
feat(cli): introduce vix make code generator system
- add MakeCommand with full CLI integration - introduce MakeDispatcher, MakeOptions, MakeResult, MakeUtils - implement generators: - class - struct - enum - function - lambda - concept - exception - test - add modular generator architecture under make/generators/ - support header-only, dry-run, print-only, force modes - integrate make into CLI and dispatcher - add preview and structured output fix: restore MakePaths.hpp and clean path handling This introduces a full scaffolding system for modern C++ development.
1 parent d4150ad commit 8830918

26 files changed

Lines changed: 2585 additions & 1027 deletions

include/vix/cli/commands/make/ MakePaths.hpp

Whitespace-only changes.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
*
3+
* @file MakeDispatcher.hpp
4+
* @author Gaspard Kirira
5+
*
6+
* Copyright 2025, Gaspard Kirira. All rights reserved.
7+
* https://github.com/vixcpp/vix
8+
* Use of this source code is governed by a MIT license
9+
* that can be found in the License file.
10+
*
11+
* Vix.cpp
12+
*
13+
*/
14+
#ifndef VIX_MAKE_DISPATCHER_HPP
15+
#define VIX_MAKE_DISPATCHER_HPP
16+
17+
#include <vix/cli/commands/make/MakeOptions.hpp>
18+
#include <vix/cli/commands/make/MakePaths.hpp>
19+
#include <vix/cli/commands/make/MakeResult.hpp>
20+
#include <vix/cli/commands/make/MakeTypes.hpp>
21+
22+
#include <string>
23+
24+
namespace vix::cli::make
25+
{
26+
struct MakeContext
27+
{
28+
MakeOptions options;
29+
MakeKind kind = MakeKind::Unknown;
30+
MakeLayout layout;
31+
std::string name;
32+
std::string name_space;
33+
};
34+
35+
[[nodiscard]] MakeKind parse_make_kind(const std::string &kind);
36+
[[nodiscard]] bool is_valid_make_kind(MakeKind kind) noexcept;
37+
38+
[[nodiscard]] MakeResult dispatch_make(const MakeOptions &options);
39+
}
40+
41+
#endif
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
*
3+
* @file MakePaths.hpp
4+
* @author Gaspard Kirira
5+
*
6+
* Copyright 2025, Gaspard Kirira. All rights reserved.
7+
* https://github.com/vixcpp/vix
8+
* Use of this source code is governed by a MIT license
9+
* that can be found in the License file.
10+
*
11+
* Vix.cpp
12+
*
13+
*/
14+
#ifndef VIX_MAKE_PATHS_HPP
15+
#define VIX_MAKE_PATHS_HPP
16+
17+
#include <filesystem>
18+
#include <string>
19+
20+
namespace vix::cli::make
21+
{
22+
struct MakeLayout
23+
{
24+
std::filesystem::path root;
25+
std::filesystem::path base;
26+
std::filesystem::path include_dir;
27+
std::filesystem::path src_dir;
28+
std::filesystem::path tests_dir;
29+
30+
std::string project;
31+
std::string default_namespace;
32+
33+
bool in_module = false;
34+
std::string module_name;
35+
};
36+
37+
[[nodiscard]] std::filesystem::path resolve_root(const std::string &dir_opt);
38+
39+
[[nodiscard]] std::string detect_project_name_from_cmake(
40+
const std::filesystem::path &root);
41+
42+
[[nodiscard]] std::string guess_default_namespace(const std::string &project);
43+
44+
[[nodiscard]] MakeLayout resolve_layout(
45+
const std::filesystem::path &root,
46+
const std::string &in_path);
47+
}
48+
49+
#endif
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
*
3+
* @file MakeUtils.hpp
4+
* @author Gaspard Kirira
5+
*
6+
* Copyright 2025, Gaspard Kirira. All rights reserved.
7+
* https://github.com/vixcpp/vix
8+
* Use of this source code is governed by a MIT license
9+
* that can be found in the License file.
10+
*
11+
* Vix.cpp
12+
*
13+
*/
14+
#ifndef VIX_MAKE_UTILS_HPP
15+
#define VIX_MAKE_UTILS_HPP
16+
17+
#include <filesystem>
18+
#include <optional>
19+
#include <string>
20+
#include <string_view>
21+
#include <vector>
22+
23+
namespace vix::cli::make
24+
{
25+
[[nodiscard]] std::string trim(std::string s);
26+
[[nodiscard]] std::string to_lower(std::string s);
27+
[[nodiscard]] std::string to_upper(std::string s);
28+
29+
[[nodiscard]] bool starts_with(std::string_view s, std::string_view prefix);
30+
[[nodiscard]] bool ends_with(std::string_view s, std::string_view suffix);
31+
32+
[[nodiscard]] bool is_identifier_start(char c);
33+
[[nodiscard]] bool is_identifier_char(char c);
34+
35+
[[nodiscard]] bool is_valid_cpp_identifier(const std::string &s);
36+
[[nodiscard]] bool is_reserved_cpp_keyword(const std::string &s);
37+
38+
[[nodiscard]] bool is_valid_namespace_token(const std::string &s);
39+
[[nodiscard]] bool is_valid_namespace_string(const std::string &ns);
40+
41+
[[nodiscard]] std::vector<std::string> split_namespace(const std::string &ns);
42+
43+
[[nodiscard]] std::string snake_case(std::string s);
44+
[[nodiscard]] std::string join_guard_parts(const std::vector<std::string> &parts);
45+
[[nodiscard]] std::string make_include_guard(const std::filesystem::path &file);
46+
47+
[[nodiscard]] std::string namespace_open(const std::string &ns);
48+
[[nodiscard]] std::string namespace_close(const std::string &ns);
49+
[[nodiscard]] std::string qualified_name(
50+
const std::string &ns,
51+
const std::string &name);
52+
53+
[[nodiscard]] bool exists_file(const std::filesystem::path &p);
54+
[[nodiscard]] bool exists_dir(const std::filesystem::path &p);
55+
[[nodiscard]] bool ensure_dir(const std::filesystem::path &p);
56+
57+
[[nodiscard]] std::optional<std::string> read_file(
58+
const std::filesystem::path &p);
59+
60+
[[nodiscard]] bool write_file_overwrite(
61+
const std::filesystem::path &p,
62+
const std::string &content);
63+
}
64+
65+
#endif
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
*
3+
* @file ClassGenerator.hpp
4+
* @author Gaspard Kirira
5+
*
6+
* Copyright 2025, Gaspard Kirira. All rights reserved.
7+
* https://github.com/vixcpp/vix
8+
* Use of this source code is governed by a MIT license
9+
* that can be found in the License file.
10+
*
11+
* Vix.cpp
12+
*
13+
*/
14+
#ifndef VIX_CLASS_GENERATOR_HPP
15+
#define VIX_CLASS_GENERATOR_HPP
16+
17+
#include <vix/cli/commands/make/MakeDispatcher.hpp>
18+
#include <vix/cli/commands/make/MakeResult.hpp>
19+
20+
namespace vix::cli::make::generators
21+
{
22+
[[nodiscard]] MakeResult generate_class(const MakeContext &ctx);
23+
}
24+
25+
#endif
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
*
3+
* @file ConceptGenerator.hpp
4+
* @author Gaspard Kirira
5+
*
6+
* Copyright 2025, Gaspard Kirira. All rights reserved.
7+
* https://github.com/vixcpp/vix
8+
* Use of this source code is governed by a MIT license
9+
* that can be found in the License file.
10+
*
11+
* Vix.cpp
12+
*
13+
*/
14+
#ifndef VIX_CONCEPT_GENERATOR_HPP
15+
#define VIX_CONCEPT_GENERATOR_HPP
16+
17+
#include <vix/cli/commands/make/MakeDispatcher.hpp>
18+
#include <vix/cli/commands/make/MakeResult.hpp>
19+
20+
namespace vix::cli::make::generators
21+
{
22+
[[nodiscard]] MakeResult generate_concept(const MakeContext &ctx);
23+
}
24+
25+
#endif
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
*
3+
* @file EnumGenerator.hpp
4+
* @author Gaspard Kirira
5+
*
6+
* Copyright 2025, Gaspard Kirira. All rights reserved.
7+
* https://github.com/vixcpp/vix
8+
* Use of this source code is governed by a MIT license
9+
* that can be found in the License file.
10+
*
11+
* Vix.cpp
12+
*
13+
*/
14+
#ifndef VIX_ENUM_GENERATOR_HPP
15+
#define VIX_ENUM_GENERATOR_HPP
16+
17+
#include <vix/cli/commands/make/MakeDispatcher.hpp>
18+
#include <vix/cli/commands/make/MakeResult.hpp>
19+
20+
namespace vix::cli::make::generators
21+
{
22+
[[nodiscard]] MakeResult generate_enum(const MakeContext &ctx);
23+
}
24+
25+
#endif
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
*
3+
* @file ExceptionGenerator.hpp
4+
* @author Gaspard Kirira
5+
*
6+
* Copyright 2025, Gaspard Kirira. All rights reserved.
7+
* https://github.com/vixcpp/vix
8+
* Use of this source code is governed by a MIT license
9+
* that can be found in the License file.
10+
*
11+
* Vix.cpp
12+
*
13+
*/
14+
#ifndef VIX_EXCEPTION_GENERATOR_HPP
15+
#define VIX_EXCEPTION_GENERATOR_HPP
16+
17+
#include <vix/cli/commands/make/MakeDispatcher.hpp>
18+
#include <vix/cli/commands/make/MakeResult.hpp>
19+
20+
namespace vix::cli::make::generators
21+
{
22+
[[nodiscard]] MakeResult generate_exception(const MakeContext &ctx);
23+
}
24+
25+
#endif
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
*
3+
* @file FunctionGenerator.hpp
4+
* @author Gaspard Kirira
5+
*
6+
* Copyright 2025, Gaspard Kirira. All rights reserved.
7+
* https://github.com/vixcpp/vix
8+
* Use of this source code is governed by a MIT license
9+
* that can be found in the License file.
10+
*
11+
* Vix.cpp
12+
*
13+
*/
14+
#ifndef VIX_FUNCTION_GENERATOR_HPP
15+
#define VIX_FUNCTION_GENERATOR_HPP
16+
17+
#include <vix/cli/commands/make/MakeDispatcher.hpp>
18+
#include <vix/cli/commands/make/MakeResult.hpp>
19+
20+
namespace vix::cli::make::generators
21+
{
22+
[[nodiscard]] MakeResult generate_function(const MakeContext &ctx);
23+
}
24+
25+
#endif
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
*
3+
* @file LambdaGenerator.hpp
4+
* @author Gaspard Kirira
5+
*
6+
* Copyright 2025, Gaspard Kirira. All rights reserved.
7+
* https://github.com/vixcpp/vix
8+
* Use of this source code is governed by a MIT license
9+
* that can be found in the License file.
10+
*
11+
* Vix.cpp
12+
*
13+
*/
14+
#ifndef VIX_LAMBDA_GENERATOR_HPP
15+
#define VIX_LAMBDA_GENERATOR_HPP
16+
17+
#include <vix/cli/commands/make/MakeDispatcher.hpp>
18+
#include <vix/cli/commands/make/MakeResult.hpp>
19+
20+
namespace vix::cli::make::generators
21+
{
22+
[[nodiscard]] MakeResult generate_lambda(const MakeContext &ctx);
23+
}
24+
25+
#endif

0 commit comments

Comments
 (0)