Skip to content

Commit 455804d

Browse files
committed
fix(cli): clean up compiler warnings in commands and generators"
2 parents 1047380 + e52493f commit 455804d

6 files changed

Lines changed: 328 additions & 165 deletions

File tree

src/commands/InstallCommand.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -272,23 +272,6 @@ namespace vix::commands
272272
return true;
273273
}
274274

275-
static std::string find_latest_version(const json &entry)
276-
{
277-
if (entry.contains("latest") && entry["latest"].is_string())
278-
return entry["latest"].get<std::string>();
279-
280-
if (!entry.contains("versions") || !entry["versions"].is_object())
281-
return {};
282-
283-
std::vector<std::string> versions;
284-
versions.reserve(entry["versions"].size());
285-
286-
for (auto it = entry["versions"].begin(); it != entry["versions"].end(); ++it)
287-
versions.push_back(it.key());
288-
289-
return vix::cli::util::semver::findLatest(versions);
290-
}
291-
292275
static int resolve_version_v1(const json &entry, PkgSpec &spec)
293276
{
294277
if (!entry.contains("versions") || !entry["versions"].is_object())

src/commands/NewCommand.cpp

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,21 @@ int main()
108108
}
109109
)";
110110

111-
constexpr const char *kBasicTestCpp_App = R"(#include <iostream>
111+
constexpr const char *kBasicTestCpp_App = R"(#include <vix/tests/TestRegistry.hpp>
112+
#include <vix/tests.hpp>
112113
113114
int main()
114115
{
115-
std::cout << "basic test OK\n";
116-
return 0;
116+
using namespace vix::tests;
117+
118+
auto &registry = TestRegistry::instance();
119+
registry.clear();
120+
121+
registry.add(TestCase("app basic test", [] {
122+
Assert::equal(2 + 2, 4);
123+
}));
124+
125+
return TestRunner::run_all_and_exit();
117126
}
118127
)";
119128

@@ -179,15 +188,26 @@ int main()
179188
static std::string make_basic_test_cpp_lib(const std::string &name)
180189
{
181190
std::string s;
182-
s.reserve(800);
191+
s.reserve(1200);
192+
193+
s += "#include <vix/tests/TestRegistry.hpp>\n";
194+
s += "#include <vix/tests/TestRunner.hpp>\n";
195+
s += "#include <vix/tests/TestCase.hpp>\n";
196+
s += "#include <vix/tests/Assert.hpp>\n";
197+
s += "#include <" + name + "/" + name + ".hpp>\n\n";
183198

184-
s += "#include <" + name + "/" + name + ".hpp>\n";
185-
s += "#include <iostream>\n\n";
186199
s += "int main()\n";
187200
s += "{\n";
188-
s += " auto nodes = " + name + "::make_chain(5);\n";
189-
s += " std::cout << \"nodes=\" << nodes.size() << \"\\n\";\n";
190-
s += " return nodes.size() == 5 ? 0 : 1;\n";
201+
s += " using namespace vix::tests;\n\n";
202+
s += " auto &registry = TestRegistry::instance();\n";
203+
s += " registry.clear();\n\n";
204+
205+
s += " registry.add(TestCase(\"" + name + " basic test\", [] {\n";
206+
s += " auto nodes = " + name + "::make_chain(5);\n";
207+
s += " Assert::equal(nodes.size(), static_cast<std::size_t>(5));\n";
208+
s += " }));\n\n";
209+
210+
s += " return TestRunner::run_all_and_exit();\n";
191211
s += "}\n";
192212

193213
return s;
@@ -803,23 +823,6 @@ int main()
803823
std::vector<bool> selected{};
804824
};
805825

806-
static bool all_checked(const std::vector<bool> &v)
807-
{
808-
if (v.empty())
809-
return false;
810-
for (bool b : v)
811-
if (!b)
812-
return false;
813-
return true;
814-
}
815-
816-
static void toggle_all(std::vector<bool> &v)
817-
{
818-
const bool turnOn = !all_checked(v);
819-
for (std::size_t i = 0; i < v.size(); ++i)
820-
v[i] = turnOn;
821-
}
822-
823826
static void render_lines(const std::vector<std::string> &lines, bool firstDraw)
824827
{
825828
const int total = (int)lines.size();
@@ -868,7 +871,7 @@ int main()
868871

869872
int cursorIndex = 0;
870873
int selectedIndex = 0;
871-
res.selected[selectedIndex] = true;
874+
res.selected[static_cast<std::size_t>(selectedIndex)] = true;
872875

873876
auto render_item = [&](const Item &item, bool active) -> std::string
874877
{
@@ -902,15 +905,15 @@ int main()
902905
out.push_back(std::string(PAD) + BOLD + CYAN + "Core" + RESET);
903906

904907
for (int i = 0; i < 3; ++i)
905-
out.push_back(render_item(items[i], i == activeIdx));
908+
out.push_back(render_item(items[static_cast<std::size_t>(i)], i == activeIdx));
906909

907910
out.push_back("");
908911

909912
out.push_back(std::string(PAD) + BOLD + CYAN + "Advanced" + RESET);
910913
out.push_back(render_item(items[3], activeIdx == 3));
911914

912915
out.push_back("");
913-
out.push_back(std::string(PAD) + ui::dim(items[activeIdx].tip));
916+
out.push_back(std::string(PAD) + ui::dim(items[static_cast<std::size_t>(activeIdx)].tip));
914917

915918
return out;
916919
};
@@ -968,7 +971,7 @@ int main()
968971
selectedIndex = cursorIndex;
969972

970973
std::fill(res.selected.begin(), res.selected.end(), false);
971-
res.selected[selectedIndex] = true;
974+
res.selected[static_cast<std::size_t>(selectedIndex)] = true;
972975

973976
if (k == Key::Enter)
974977
{
@@ -1437,7 +1440,7 @@ int main()
14371440
s += " }\n";
14381441
s += " },\n";
14391442
s += " \"test\": {\n";
1440-
s += " \"description\": \"Run CTest suite\",\n";
1443+
s += " \"description\": \"Run project tests\",\n";
14411444
s += " \"command\": \"vix tests --preset ${preset} --fail-fast\"\n";
14421445
s += " },\n";
14431446
s += " \"dev\": {\n";

src/commands/PublishCommand.cpp

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -560,24 +560,6 @@ namespace vix::commands
560560
}
561561
}
562562

563-
static std::optional<std::string> read_vix_json_namespace(const fs::path &repoRoot)
564-
{
565-
const fs::path p = repoRoot / "vix.json";
566-
if (!file_exists_nonempty(p))
567-
return std::nullopt;
568-
569-
try
570-
{
571-
const json j = read_json_or_throw(p);
572-
if (j.is_object() && j.contains("namespace") && j["namespace"].is_string())
573-
return lower_copy(j["namespace"].get<std::string>());
574-
}
575-
catch (...)
576-
{
577-
}
578-
return std::nullopt;
579-
}
580-
581563
static bool looks_like_semver_tag(const std::string &tag)
582564
{
583565
std::string s = trim_copy(tag);
@@ -679,24 +661,6 @@ namespace vix::commands
679661
return detected;
680662
}
681663

682-
static std::optional<std::string> read_vix_json_name(const fs::path &repoRoot)
683-
{
684-
const fs::path p = repoRoot / "vix.json";
685-
if (!file_exists_nonempty(p))
686-
return std::nullopt;
687-
688-
try
689-
{
690-
const json j = read_json_or_throw(p);
691-
if (j.is_object() && j.contains("name") && j["name"].is_string())
692-
return lower_copy(j["name"].get<std::string>());
693-
}
694-
catch (...)
695-
{
696-
}
697-
return std::nullopt;
698-
}
699-
700664
static json read_vix_json_object(const fs::path &repoRoot)
701665
{
702666
const fs::path p = repoRoot / "vix.json";

0 commit comments

Comments
 (0)