diff options
| author | Lexi Winter <lexi@le-fay.org> | 2025-06-29 17:16:22 +0100 |
|---|---|---|
| committer | Lexi Winter <lexi@le-fay.org> | 2025-06-29 17:16:22 +0100 |
| commit | 4fa6821e0645ff61a9380cd090abff472205c630 (patch) | |
| tree | bd95f13b2dc0bd9692681f50c365d2914a520bfe /nihil.cli | |
| parent | e5180acf5f2dfac788e8c12886095ed1ac66fae5 (diff) | |
| download | nihil-4fa6821e0645ff61a9380cd090abff472205c630.tar.gz nihil-4fa6821e0645ff61a9380cd090abff472205c630.tar.bz2 | |
add clang-tidy support
Diffstat (limited to 'nihil.cli')
| -rw-r--r-- | nihil.cli/command.cc | 1 | ||||
| -rw-r--r-- | nihil.cli/command_node.cc | 9 | ||||
| -rw-r--r-- | nihil.cli/command_path.ccm | 16 | ||||
| -rw-r--r-- | nihil.cli/test.cc | 12 |
4 files changed, 17 insertions, 21 deletions
diff --git a/nihil.cli/command.cc b/nihil.cli/command.cc index 475cad0..725b4eb 100644 --- a/nihil.cli/command.cc +++ b/nihil.cli/command.cc @@ -22,6 +22,7 @@ import :registry; namespace nihil { +//NOLINTNEXTLINE(bugprone-easily-swappable-parameters) command::command(std::string_view path, std::string_view usage, command_function_t handler) : command_node(path) diff --git a/nihil.cli/command_node.cc b/nihil.cli/command_node.cc index 98aeac1..dd18716 100644 --- a/nihil.cli/command_node.cc +++ b/nihil.cli/command_node.cc @@ -9,6 +9,8 @@ module; #include <print> #include <string> +#include <unistd.h> + module nihil.cli; import nihil.core; @@ -16,9 +18,14 @@ import nihil.error; namespace nihil { +//NOLINTNEXTLINE(bugprone-exception-escape) command_node::command_node(std::string_view path) noexcept - : m_path(path) +try : m_path(path) { +} catch (std::exception const &exc) { + std::fprintf(stderr, "%s\n", exc.what()); + _exit(1); + /*NOTREACHED*/ } command_node::~command_node() diff --git a/nihil.cli/command_path.ccm b/nihil.cli/command_path.ccm deleted file mode 100644 index a5bd5e3..0000000 --- a/nihil.cli/command_path.ccm +++ /dev/null @@ -1,16 +0,0 @@ -/* - * This source code is released into the public domain. - */ - -module; - -/* - * command_path represents a command split into its component parts. - */ - -export module nihil.cli:command_path; - -namespace nihil { - - -} // namespace nihil diff --git a/nihil.cli/test.cc b/nihil.cli/test.cc index c265700..c82281e 100644 --- a/nihil.cli/test.cc +++ b/nihil.cli/test.cc @@ -36,7 +36,8 @@ TEST_CASE("nihil.cli: dispatch_command: basic", "[nihil.cli]") }; auto argv = const_cast<char **>(args.data()); - int ret = nihil::dispatch_command(args.size() - 1, argv); + int ret = nihil::dispatch_command( + static_cast<int>(args.size()) - 1, argv); REQUIRE(ret == 0); REQUIRE(cmd_sub1_called == true); REQUIRE(cmd_sub2_called == false); @@ -48,7 +49,8 @@ TEST_CASE("nihil.cli: dispatch_command: basic", "[nihil.cli]") }; auto argv = const_cast<char **>(args.data()); - int ret = nihil::dispatch_command(args.size() - 1, argv); + int ret = nihil::dispatch_command( + static_cast<int>(args.size()) - 1, argv); REQUIRE(ret == 0); REQUIRE(cmd_sub2_called == true); } @@ -65,7 +67,8 @@ TEST_CASE("nihil.cli: dispatch_command: unknown command", "[nihil.cli]") auto ret = int{}; { auto capture = nihil::capture_stream(std::cerr); - ret = nihil::dispatch_command(args.size() - 1, argv); + ret = nihil::dispatch_command( + static_cast<int>(args.size()) - 1, argv); std::cerr.flush(); output = capture.str(); } @@ -87,7 +90,8 @@ TEST_CASE("nihil.cli: dispatch_command: incomplete command", "[nihil.cli]") auto ret = int{}; { auto capture = nihil::capture_stream(std::cerr); - ret = nihil::dispatch_command(args.size() - 1, argv); + ret = nihil::dispatch_command( + static_cast<int>(args.size()) - 1, argv); std::cerr.flush(); output = capture.str(); } |
