Skip to content

Commit 2ca123d

Browse files
committed
Polish modules command output
1 parent 4133e5e commit 2ca123d

2 files changed

Lines changed: 90 additions & 20 deletions

File tree

src/commands/ModulesCommand.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ namespace vix::commands::ModulesCommand
113113

114114
if (opt.subcmd == "init")
115115
{
116-
ui::section(std::cout, "Modules");
117116
return cmds::cmd_init(root, opt.patchRoot) ? 0 : 1;
118117
}
119118

@@ -125,13 +124,12 @@ namespace vix::commands::ModulesCommand
125124
ui::warn_line(std::cout, "Usage: vix modules add <name>");
126125
return 1;
127126
}
128-
ui::section(std::cout, "Modules");
127+
129128
return cmds::cmd_add(root, project, opt.module, opt.patchLink) ? 0 : 1;
130129
}
131130

132131
if (opt.subcmd == "check")
133132
{
134-
ui::section(std::cout, "Modules");
135133
return cmds::cmd_check(root, project) ? 0 : 1;
136134
}
137135

src/commands/modules/ModulesCommands.cpp

Lines changed: 89 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,44 @@ namespace vix::commands::modules_cmd::commands
2828
namespace ui = vix::cli::util;
2929
using namespace vix::cli::style;
3030

31+
static constexpr const char *TEAL = "\033[38;5;35m";
32+
33+
static void sep()
34+
{
35+
std::cout << PAD << GRAY << "─────────────────────────────────────" << RESET << "\n";
36+
}
37+
38+
static void section(const std::string &title)
39+
{
40+
std::cout << PAD << GRAY << title << RESET << "\n";
41+
}
42+
43+
static void print_command_step(
44+
int index,
45+
const std::string &cmd,
46+
const std::string &hint = "")
47+
{
48+
std::cout << PAD
49+
<< GRAY << index << RESET
50+
<< " "
51+
<< CYAN << BOLD << cmd << RESET;
52+
53+
if (!hint.empty())
54+
std::cout << " " << GRAY << hint << RESET;
55+
56+
std::cout << "\n";
57+
}
58+
59+
static void print_modules_banner(
60+
const std::string &name,
61+
const std::string &kind)
62+
{
63+
std::cout << PAD << TEAL << BOLD << "" << RESET
64+
<< " " << TEAL << BOLD << name << RESET
65+
<< " " << GRAY << kind << RESET
66+
<< "\n";
67+
}
68+
3169
bool cmd_init(const fs::path &root, bool patchRoot)
3270
{
3371
const fs::path modulesDir = root / "modules";
@@ -58,12 +96,19 @@ namespace vix::commands::modules_cmd::commands
5896
return false;
5997
}
6098

61-
ui::ok_line(std::cout, "Modules mode initialized");
62-
ui::kv(std::cout, "modules", (root / "modules").string(), 10);
63-
ui::kv(std::cout, "cmake", (root / "cmake" / "vix_modules.cmake").string(), 10);
99+
print_modules_banner("modules", "initialized");
100+
sep();
101+
102+
section("files");
103+
print_command_step(1, "modules/", "module directory");
104+
print_command_step(2, "cmake/vix_modules.cmake", "module loader");
105+
64106
if (patchRoot)
65-
ui::kv(std::cout, "patch", "root CMakeLists.txt updated (idempotent markers)", 10);
66-
ui::warn_line(std::cout, "Next: vix modules add <name>");
107+
print_command_step(3, "CMakeLists.txt", "patched");
108+
109+
sep();
110+
section("next");
111+
print_command_step(1, "vix modules add <name>", "create module");
67112

68113
return true;
69114
}
@@ -148,20 +193,47 @@ namespace vix::commands::modules_cmd::commands
148193
return false;
149194
}
150195

151-
ui::ok_line(std::cout, "Module created");
152-
ui::kv(std::cout, "name", normalized, 10);
153-
ui::kv(std::cout, "target", cnt::module_alias_name(project, module), 10);
154-
ui::kv(std::cout, "public", "modules/" + normalized + "/include/" + normalized + "/api.hpp", 10);
155-
ui::kv(std::cout, "impl", "modules/" + normalized + "/src/" + normalized + ".cpp", 10);
196+
print_modules_banner(normalized, "module");
197+
sep();
198+
199+
section("files");
200+
print_command_step(
201+
1,
202+
"modules/" + normalized + "/include/" + normalized + "/api.hpp",
203+
"public header");
204+
205+
print_command_step(
206+
2,
207+
"modules/" + normalized + "/src/" + normalized + ".cpp",
208+
"implementation");
209+
210+
print_command_step(
211+
3,
212+
"modules/" + normalized + "/CMakeLists.txt",
213+
"target");
214+
215+
sep();
216+
section("target");
217+
print_command_step(1, cnt::module_alias_name(project, module), "CMake alias");
218+
219+
sep();
220+
section("next");
221+
print_command_step(
222+
1,
223+
"#include <" + normalized + "/api.hpp>",
224+
"include");
156225

157-
ui::warn_line(std::cout, "Next steps (CMake):");
158-
std::cout << " " << GRAY << "" << RESET
159-
<< "Include: " << YELLOW << BOLD << "#include <" << normalized << "/api.hpp>" << RESET << "\n";
160226
if (patchRootLink)
161-
std::cout << " " << GRAY << "" << RESET
162-
<< "Root: " << GRAY
163-
<< "(auto-linked if main target is named like project(" << project << "))"
164-
<< RESET << "\n";
227+
{
228+
print_command_step(2, "vix build", "compile");
229+
}
230+
else
231+
{
232+
print_command_step(
233+
2,
234+
"target_link_libraries(" + project + " PRIVATE " + cnt::module_alias_name(project, module) + ")",
235+
"link manually");
236+
}
165237

166238
return true;
167239
}

0 commit comments

Comments
 (0)