aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt10
-rw-r--r--nihil.cli/CMakeLists.txt32
-rw-r--r--nihil.cli/command_map.cc (renamed from nihil/command_map.cc)2
-rw-r--r--nihil.cli/command_map.ccm (renamed from nihil/command_map.ccm)4
-rw-r--r--nihil.cli/nihil.cli.ccm9
-rw-r--r--nihil.cli/test_command_map.cc (renamed from nihil/tests/command_map.cc)2
-rw-r--r--nihil.cli/usage_error.ccm (renamed from nihil/usage_error.ccm)4
-rw-r--r--nihil.config/CMakeLists.txt7
-rw-r--r--nihil.config/option.cc3
-rw-r--r--nihil.config/option.ccm2
-rw-r--r--nihil.config/read.cc4
-rw-r--r--nihil.config/read.ccm2
-rw-r--r--nihil.config/store.cc4
-rw-r--r--nihil.config/store.ccm2
-rw-r--r--nihil.config/string.cc3
-rw-r--r--nihil.config/string.ccm1
-rw-r--r--nihil.config/write.cc4
-rw-r--r--nihil.config/write.ccm2
-rw-r--r--nihil.error/CMakeLists.txt29
-rw-r--r--nihil.error/error.cc (renamed from nihil/error.cc)5
-rw-r--r--nihil.error/error.ccm (renamed from nihil/error.ccm)2
-rw-r--r--nihil.error/test.cc (renamed from nihil/tests/error.cc)2
-rw-r--r--nihil.generator/CMakeLists.txt23
-rw-r--r--nihil.generator/generator.ccm (renamed from nihil/generator.ccm)2
-rw-r--r--nihil.generator/test.cc (renamed from nihil/tests/generator.cc)2
-rw-r--r--nihil.guard/CMakeLists.txt23
-rw-r--r--nihil.guard/guard.ccm (renamed from nihil/guard.ccm)2
-rw-r--r--nihil.guard/test.cc (renamed from nihil/tests/guard.cc)2
-rw-r--r--nihil.match/CMakeLists.txt23
-rw-r--r--nihil.match/match.ccm (renamed from nihil/match.ccm)6
-rw-r--r--nihil.match/test.cc34
-rw-r--r--nihil.monad/CMakeLists.txt24
-rw-r--r--nihil.monad/monad.ccm (renamed from nihil/monad.ccm)2
-rw-r--r--nihil.monad/test.cc (renamed from nihil/tests/monad.cc)3
-rw-r--r--nihil.posix/CMakeLists.txt51
-rw-r--r--nihil.posix/argv.cc (renamed from nihil/argv.cc)2
-rw-r--r--nihil.posix/argv.ccm (renamed from nihil/argv.ccm)2
-rw-r--r--nihil.posix/ensure_dir.cc (renamed from nihil/ensure_dir.cc)4
-rw-r--r--nihil.posix/ensure_dir.ccm (renamed from nihil/ensure_dir.ccm)4
-rw-r--r--nihil.posix/exec.cc (renamed from nihil/exec.cc)7
-rw-r--r--nihil.posix/exec.ccm (renamed from nihil/exec.ccm)5
-rw-r--r--nihil.posix/fd.cc (renamed from nihil/fd.cc)5
-rw-r--r--nihil.posix/fd.ccm (renamed from nihil/fd.ccm)5
-rw-r--r--nihil.posix/find_in_path.cc (renamed from nihil/find_in_path.cc)8
-rw-r--r--nihil.posix/getenv.cc (renamed from nihil/getenv.cc)4
-rw-r--r--nihil.posix/nihil.posix.ccm45
-rw-r--r--nihil.posix/open.cc (renamed from nihil/open_file.cc)7
-rw-r--r--nihil.posix/open.ccm (renamed from nihil/open_file.ccm)11
-rw-r--r--nihil.posix/process.cc (renamed from nihil/process.cc)4
-rw-r--r--nihil.posix/process.ccm (renamed from nihil/process.ccm)4
-rw-r--r--nihil.posix/read_file.ccm (renamed from nihil/read_file.ccm)10
-rw-r--r--nihil.posix/rename.cc (renamed from nihil/rename_file.cc)4
-rw-r--r--nihil.posix/rename.ccm (renamed from nihil/rename_file.ccm)7
-rw-r--r--nihil.posix/spawn.ccm (renamed from nihil/spawn.ccm)9
-rw-r--r--nihil.posix/test_fd.cc (renamed from nihil/tests/fd.cc)3
-rw-r--r--nihil.posix/test_getenv.cc (renamed from nihil/tests/getenv.cc)9
-rw-r--r--nihil.posix/test_spawn.cc (renamed from nihil/tests/spawn.cc)2
-rw-r--r--nihil.posix/write_file.ccm (renamed from nihil/write_file.ccm)17
-rw-r--r--nihil.ucl/CMakeLists.txt2
-rw-r--r--nihil.ucl/boolean.cc2
-rw-r--r--nihil.ucl/errc.cc2
-rw-r--r--nihil.ucl/integer.cc2
-rw-r--r--nihil.ucl/integer.ccm1
-rw-r--r--nihil.ucl/object.cc2
-rw-r--r--nihil.ucl/object.ccm1
-rw-r--r--nihil.ucl/object_cast.ccm2
-rw-r--r--nihil.ucl/parser.cc2
-rw-r--r--nihil.ucl/parser.ccm2
-rw-r--r--nihil.ucl/real.cc2
-rw-r--r--nihil.ucl/string.cc2
-rw-r--r--nihil.ucl/string.ccm1
-rw-r--r--nihil.ucl/tests/CMakeLists.txt4
-rw-r--r--nihil.ucl/tests/array.cc1
-rw-r--r--nihil.ucl/tests/emit.cc1
-rw-r--r--nihil.ucl/tests/parse.cc1
-rw-r--r--nihil.ucl/type.ccm2
-rw-r--r--nihil.util/CMakeLists.txt36
-rw-r--r--nihil.util/ctype.ccm (renamed from nihil/ctype.ccm)2
-rw-r--r--nihil.util/next_word.ccm (renamed from nihil/next_word.ccm)3
-rw-r--r--nihil.util/nihil.util.ccm13
-rw-r--r--nihil.util/parse_size.ccm (renamed from nihil/parse_size.ccm)8
-rw-r--r--nihil.util/skipws.ccm (renamed from nihil/skipws.ccm)2
-rw-r--r--nihil.util/tabulate.ccm (renamed from nihil/tabulate.ccm)4
-rw-r--r--nihil.util/test_ctype.cc (renamed from nihil/tests/ctype.cc)2
-rw-r--r--nihil.util/test_next_word.cc (renamed from nihil/tests/next_word.cc)2
-rw-r--r--nihil.util/test_parse_size.cc (renamed from nihil/tests/parse_size.cc)3
-rw-r--r--nihil.util/test_skipws.cc (renamed from nihil/tests/skipws.cc)2
-rw-r--r--nihil.util/test_tabulate.cc (renamed from nihil/tests/tabulate.cc)2
-rw-r--r--nihil/CMakeLists.txt52
-rw-r--r--nihil/errc.cc49
-rw-r--r--nihil/errc.ccm34
-rw-r--r--nihil/find_in_path.ccm24
-rw-r--r--nihil/format_filesystem.ccm35
-rw-r--r--nihil/getenv.ccm24
-rw-r--r--nihil/nihil.ccm34
-rw-r--r--nihil/tests/CMakeLists.txt28
96 files changed, 497 insertions, 404 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9a2b6ab..8bf5a42 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,9 +18,17 @@ add_compile_options(-Wextra)
add_compile_options(-Werror)
add_compile_options(-Wpedantic)
+add_subdirectory(nihil.cli)
+add_subdirectory(nihil.core)
+add_subdirectory(nihil.error)
add_subdirectory(nihil.flagset)
+add_subdirectory(nihil.generator)
+add_subdirectory(nihil.guard)
+add_subdirectory(nihil.match)
+add_subdirectory(nihil.monad)
+add_subdirectory(nihil.posix)
+add_subdirectory(nihil.util)
add_subdirectory(nihil.uuid)
-add_subdirectory(nihil)
if(NIHIL_UCL)
add_subdirectory(nihil.ucl)
diff --git a/nihil.cli/CMakeLists.txt b/nihil.cli/CMakeLists.txt
new file mode 100644
index 0000000..a677798
--- /dev/null
+++ b/nihil.cli/CMakeLists.txt
@@ -0,0 +1,32 @@
+# This source code is released into the public domain.
+
+add_library(nihil.cli STATIC)
+target_link_libraries(nihil.cli PRIVATE nihil.util)
+target_sources(nihil.cli
+ PUBLIC FILE_SET modules TYPE CXX_MODULES FILES
+ nihil.cli.ccm
+
+ command_map.ccm
+ usage_error.ccm
+
+ PRIVATE
+ command_map.cc
+)
+
+if(NIHIL_TESTS)
+ enable_testing()
+
+ add_executable(nihil.cli.test
+ test_command_map.cc
+ )
+ target_link_libraries(nihil.cli.test PRIVATE
+ nihil.cli
+ Catch2::Catch2WithMain
+ )
+
+ find_package(Catch2 REQUIRED)
+
+ include(CTest)
+ include(Catch)
+ catch_discover_tests(nihil.cli.test)
+endif()
diff --git a/nihil/command_map.cc b/nihil.cli/command_map.cc
index e02d270..c656c62 100644
--- a/nihil/command_map.cc
+++ b/nihil.cli/command_map.cc
@@ -14,7 +14,7 @@ module;
#include <unistd.h>
-module nihil;
+module nihil.cli;
/*
* command_map represents a hierarchical list of commands. At each level,
diff --git a/nihil/command_map.ccm b/nihil.cli/command_map.ccm
index 3c58ecc..8cf9d9c 100644
--- a/nihil/command_map.ccm
+++ b/nihil.cli/command_map.ccm
@@ -10,9 +10,9 @@ module;
#include <string>
#include <utility>
-export module nihil:command_map;
+export module nihil.cli:command_map;
-import :next_word;
+import nihil.util;
import :usage_error;
/*
diff --git a/nihil.cli/nihil.cli.ccm b/nihil.cli/nihil.cli.ccm
new file mode 100644
index 0000000..faeb44e
--- /dev/null
+++ b/nihil.cli/nihil.cli.ccm
@@ -0,0 +1,9 @@
+/*
+ * This source code is released into the public domain.
+ */
+
+module;
+
+export module nihil.cli;
+
+export import :command_map;
diff --git a/nihil/tests/command_map.cc b/nihil.cli/test_command_map.cc
index de78be5..1b87a49 100644
--- a/nihil/tests/command_map.cc
+++ b/nihil.cli/test_command_map.cc
@@ -6,7 +6,7 @@
#include <catch2/catch_test_macros.hpp>
-import nihil;
+import nihil.cli;
namespace {
diff --git a/nihil/usage_error.ccm b/nihil.cli/usage_error.ccm
index abbd6f0..11646e6 100644
--- a/nihil/usage_error.ccm
+++ b/nihil.cli/usage_error.ccm
@@ -6,9 +6,9 @@ module;
#include <string>
-export module nihil:usage_error;
+export module nihil.cli:usage_error;
-import :error;
+import nihil.error;
namespace nihil {
diff --git a/nihil.config/CMakeLists.txt b/nihil.config/CMakeLists.txt
index fb2c1db..8a52d3c 100644
--- a/nihil.config/CMakeLists.txt
+++ b/nihil.config/CMakeLists.txt
@@ -1,7 +1,12 @@
# This source code is released into the public domain.
add_library(nihil.config STATIC)
-target_link_libraries(nihil.config PUBLIC nihil nihil.ucl)
+target_link_libraries(nihil.config PRIVATE
+ nihil.error
+ nihil.generator
+ nihil.posix
+ nihil.ucl
+)
target_sources(nihil.config
PUBLIC FILE_SET modules TYPE CXX_MODULES FILES
nihil.config.ccm
diff --git a/nihil.config/option.cc b/nihil.config/option.cc
index 588a48f..bcaf167 100644
--- a/nihil.config/option.cc
+++ b/nihil.config/option.cc
@@ -11,7 +11,8 @@ module;
module nihil.config;
-import nihil;
+import nihil.error;
+import nihil.monad;
import nihil.ucl;
namespace nihil::config {
diff --git a/nihil.config/option.ccm b/nihil.config/option.ccm
index c6ebcae..4b95793 100644
--- a/nihil.config/option.ccm
+++ b/nihil.config/option.ccm
@@ -10,7 +10,7 @@ module;
export module nihil.config:option;
-import nihil;
+import nihil.error;
import nihil.ucl;
namespace nihil::config {
diff --git a/nihil.config/read.cc b/nihil.config/read.cc
index e7def91..48484fb 100644
--- a/nihil.config/read.cc
+++ b/nihil.config/read.cc
@@ -13,7 +13,9 @@ module;
module nihil.config;
-import nihil;
+import nihil.error;
+import nihil.monad;
+import nihil.posix;
import nihil.ucl;
namespace nihil::config {
diff --git a/nihil.config/read.ccm b/nihil.config/read.ccm
index fca78eb..9cf28c9 100644
--- a/nihil.config/read.ccm
+++ b/nihil.config/read.ccm
@@ -9,7 +9,7 @@ module;
export module nihil.config:read;
-import nihil;
+import nihil.error;
namespace nihil::config {
diff --git a/nihil.config/store.cc b/nihil.config/store.cc
index 6f93677..0fb8cc0 100644
--- a/nihil.config/store.cc
+++ b/nihil.config/store.cc
@@ -12,7 +12,9 @@ module;
module nihil.config;
-import nihil;
+import nihil.error;
+import nihil.generator;
+import nihil.monad;
namespace nihil::config {
diff --git a/nihil.config/store.ccm b/nihil.config/store.ccm
index 03d09d3..4d37ce0 100644
--- a/nihil.config/store.ccm
+++ b/nihil.config/store.ccm
@@ -15,7 +15,7 @@ module;
export module nihil.config:store;
-import nihil;
+import nihil.generator;
import :option;
namespace nihil::config {
diff --git a/nihil.config/string.cc b/nihil.config/string.cc
index 7d0c038..0ca4605 100644
--- a/nihil.config/string.cc
+++ b/nihil.config/string.cc
@@ -11,7 +11,8 @@ module;
module nihil.config;
-import nihil;
+import nihil.error;
+import nihil.monad;
import nihil.ucl;
namespace nihil::config {
diff --git a/nihil.config/string.ccm b/nihil.config/string.ccm
index b6a7e05..668bbc0 100644
--- a/nihil.config/string.ccm
+++ b/nihil.config/string.ccm
@@ -10,7 +10,6 @@ module;
export module nihil.config:string;
-import nihil;
import nihil.ucl;
import :option;
diff --git a/nihil.config/write.cc b/nihil.config/write.cc
index 8c02c43..80125a8 100644
--- a/nihil.config/write.cc
+++ b/nihil.config/write.cc
@@ -12,7 +12,9 @@ module;
module nihil.config;
-import nihil;
+import nihil.error;
+import nihil.monad;
+import nihil.posix;
import nihil.ucl;
namespace nihil::config {
diff --git a/nihil.config/write.ccm b/nihil.config/write.ccm
index 8fb8151..564bb20 100644
--- a/nihil.config/write.ccm
+++ b/nihil.config/write.ccm
@@ -9,7 +9,7 @@ module;
export module nihil.config:write;
-import nihil;
+import nihil.error;
namespace nihil::config {
diff --git a/nihil.error/CMakeLists.txt b/nihil.error/CMakeLists.txt
new file mode 100644
index 0000000..1316b71
--- /dev/null
+++ b/nihil.error/CMakeLists.txt
@@ -0,0 +1,29 @@
+# This source code is released into the public domain.
+
+add_library(nihil.error STATIC)
+target_link_libraries(nihil.error PRIVATE nihil.match)
+target_sources(nihil.error
+ PUBLIC FILE_SET modules TYPE CXX_MODULES FILES
+ error.ccm
+
+ PRIVATE
+ error.cc
+)
+
+if(NIHIL_TESTS)
+ enable_testing()
+
+ add_executable(nihil.error.test
+ test.cc)
+
+ target_link_libraries(nihil.error.test PRIVATE
+ nihil.error
+ Catch2::Catch2WithMain
+ )
+
+ find_package(Catch2 REQUIRED)
+
+ include(CTest)
+ include(Catch)
+ catch_discover_tests(nihil.error.test)
+endif()
diff --git a/nihil/error.cc b/nihil.error/error.cc
index c2cfd49..15805a3 100644
--- a/nihil/error.cc
+++ b/nihil.error/error.cc
@@ -4,13 +4,16 @@
module;
+#include <iostream>
#include <memory>
#include <optional>
#include <string>
#include <system_error>
#include <variant>
-module nihil;
+module nihil.error;
+
+import nihil.match;
namespace nihil {
diff --git a/nihil/error.ccm b/nihil.error/error.ccm
index 0500f2e..b624184 100644
--- a/nihil/error.ccm
+++ b/nihil.error/error.ccm
@@ -36,7 +36,7 @@ module;
#include <utility>
#include <variant>
-export module nihil:error;
+export module nihil.error;
namespace nihil {
diff --git a/nihil/tests/error.cc b/nihil.error/test.cc
index 31124e3..9b3eef1 100644
--- a/nihil/tests/error.cc
+++ b/nihil.error/test.cc
@@ -8,7 +8,7 @@
#include <catch2/catch_test_macros.hpp>
-import nihil;
+import nihil.error;
TEST_CASE("error: invariants", "[nihil]")
{
diff --git a/nihil.generator/CMakeLists.txt b/nihil.generator/CMakeLists.txt
new file mode 100644
index 0000000..7d278a8
--- /dev/null
+++ b/nihil.generator/CMakeLists.txt
@@ -0,0 +1,23 @@
+# This source code is released into the public domain.
+
+add_library(nihil.generator STATIC)
+target_sources(nihil.generator
+ PUBLIC FILE_SET modules TYPE CXX_MODULES FILES
+ generator.ccm
+)
+
+if(NIHIL_TESTS)
+ enable_testing()
+
+ add_executable(nihil.generator.test test.cc)
+ target_link_libraries(nihil.generator.test PRIVATE
+ nihil.generator
+ Catch2::Catch2WithMain
+ )
+
+ find_package(Catch2 REQUIRED)
+
+ include(CTest)
+ include(Catch)
+ catch_discover_tests(nihil.generator.test)
+endif()
diff --git a/nihil/generator.ccm b/nihil.generator/generator.ccm
index b5a23ee..f022287 100644
--- a/nihil/generator.ccm
+++ b/nihil.generator/generator.ccm
@@ -21,7 +21,7 @@ module;
#include <type_traits>
#include <utility>
-export module nihil:generator;
+export module nihil.generator;
namespace nihil {
diff --git a/nihil/tests/generator.cc b/nihil.generator/test.cc
index 8657756..d167f30 100644
--- a/nihil/tests/generator.cc
+++ b/nihil.generator/test.cc
@@ -8,7 +8,7 @@
#include <catch2/catch_test_macros.hpp>
-import nihil;
+import nihil.generator;
TEST_CASE("generator: basic", "[generator]")
{
diff --git a/nihil.guard/CMakeLists.txt b/nihil.guard/CMakeLists.txt
new file mode 100644
index 0000000..bba4284
--- /dev/null
+++ b/nihil.guard/CMakeLists.txt
@@ -0,0 +1,23 @@
+# This source code is released into the public domain.
+
+add_library(nihil.guard STATIC)
+target_sources(nihil.guard
+ PUBLIC FILE_SET modules TYPE CXX_MODULES FILES
+ guard.ccm
+)
+
+if(NIHIL_TESTS)
+ enable_testing()
+
+ add_executable(nihil.guard.test test.cc)
+ target_link_libraries(nihil.guard.test PRIVATE
+ nihil.guard
+ Catch2::Catch2WithMain
+ )
+
+ find_package(Catch2 REQUIRED)
+
+ include(CTest)
+ include(Catch)
+ catch_discover_tests(nihil.guard.test)
+endif()
diff --git a/nihil/guard.ccm b/nihil.guard/guard.ccm
index 554f605..c586a20 100644
--- a/nihil/guard.ccm
+++ b/nihil.guard/guard.ccm
@@ -9,7 +9,7 @@ module;
#include <optional>
#include <utility>
-export module nihil:guard;
+export module nihil.guard;
namespace nihil {
diff --git a/nihil/tests/guard.cc b/nihil.guard/test.cc
index f88aa9b..11f7d37 100644
--- a/nihil/tests/guard.cc
+++ b/nihil.guard/test.cc
@@ -4,7 +4,7 @@
#include <catch2/catch_test_macros.hpp>
-import nihil;
+import nihil.guard;
using namespace std::literals;
diff --git a/nihil.match/CMakeLists.txt b/nihil.match/CMakeLists.txt
new file mode 100644
index 0000000..d7c5875
--- /dev/null
+++ b/nihil.match/CMakeLists.txt
@@ -0,0 +1,23 @@
+# This source code is released into the public domain.
+
+add_library(nihil.match STATIC)
+target_sources(nihil.match
+ PUBLIC FILE_SET modules TYPE CXX_MODULES FILES
+ match.ccm
+)
+
+if(NIHIL_TESTS)
+ enable_testing()
+
+ add_executable(nihil.match.test test.cc)
+ target_link_libraries(nihil.match.test PRIVATE
+ nihil.match
+ Catch2::Catch2WithMain
+ )
+
+ find_package(Catch2 REQUIRED)
+
+ include(CTest)
+ include(Catch)
+ catch_discover_tests(nihil.match.test)
+endif()
diff --git a/nihil/match.ccm b/nihil.match/match.ccm
index f51ce4b..d67bd0b 100644
--- a/nihil/match.ccm
+++ b/nihil.match/match.ccm
@@ -6,7 +6,7 @@ module;
#include <variant>
-export module nihil:match;
+export module nihil.match;
namespace nihil {
@@ -14,8 +14,8 @@ export template<class... Ts>
struct match : Ts... { using Ts::operator()...; };
export template<typename... Ts, typename... Fs>
-constexpr decltype(auto) operator| (std::variant<Ts...> const &v,
- match<Fs...> const &match)
+[[nodiscard]] constexpr decltype(auto) operator|
+ (std::variant<Ts...> const &v, match<Fs...> const &match)
{
return std::visit(match, v);
}
diff --git a/nihil.match/test.cc b/nihil.match/test.cc
new file mode 100644
index 0000000..7dd1c34
--- /dev/null
+++ b/nihil.match/test.cc
@@ -0,0 +1,34 @@
+/*
+ * This source code is released into the public domain.
+ */
+
+#include <string>
+#include <variant>
+
+#include <catch2/catch_test_macros.hpp>
+
+import nihil.match;
+
+TEST_CASE("match", "[nihil]")
+{
+ using namespace nihil;
+ using namespace std::literals;
+
+ auto v = std::variant<int, std::string>(42);
+
+ auto s = v | match {
+ [](int) { return "int"s; },
+ [](std::string const &) { return "string"s; }
+ };
+
+ REQUIRE(s == "int");
+
+ v = "test"s;
+
+ s = v | match {
+ [](int) { return "int"s; },
+ [](std::string const &) { return "string"s; }
+ };
+
+ REQUIRE(s == "string");
+}
diff --git a/nihil.monad/CMakeLists.txt b/nihil.monad/CMakeLists.txt
new file mode 100644
index 0000000..b0fa095
--- /dev/null
+++ b/nihil.monad/CMakeLists.txt
@@ -0,0 +1,24 @@
+# This source code is released into the public domain.
+
+add_library(nihil.monad STATIC)
+target_link_libraries(nihil.monad PRIVATE nihil.error)
+target_sources(nihil.monad
+ PUBLIC FILE_SET modules TYPE CXX_MODULES FILES
+ monad.ccm
+)
+
+if(NIHIL_TESTS)
+ enable_testing()
+
+ add_executable(nihil.monad.test test.cc)
+ target_link_libraries(nihil.monad.test PRIVATE
+ nihil.monad
+ Catch2::Catch2WithMain
+ )
+
+ find_package(Catch2 REQUIRED)
+
+ include(CTest)
+ include(Catch)
+ catch_discover_tests(nihil.monad.test)
+endif()
diff --git a/nihil/monad.ccm b/nihil.monad/monad.ccm
index 9a2db2e..b462e4c 100644
--- a/nihil/monad.ccm
+++ b/nihil.monad/monad.ccm
@@ -30,7 +30,7 @@ module;
#include <optional>
#include <utility>
-export module nihil:monad;
+export module nihil.monad;
namespace nihil {
diff --git a/nihil/tests/monad.cc b/nihil.monad/test.cc
index 3964494..347acdb 100644
--- a/nihil/tests/monad.cc
+++ b/nihil.monad/test.cc
@@ -8,7 +8,8 @@
#include <catch2/catch_test_macros.hpp>
-import nihil;
+import nihil.error;
+import nihil.monad;
TEST_CASE("monad: co_await std::optional<> with value", "[nihil]")
{
diff --git a/nihil.posix/CMakeLists.txt b/nihil.posix/CMakeLists.txt
new file mode 100644
index 0000000..db5e5aa
--- /dev/null
+++ b/nihil.posix/CMakeLists.txt
@@ -0,0 +1,51 @@
+# This source code is released into the public domain.
+
+add_library(nihil.posix STATIC)
+target_link_libraries(nihil.posix PRIVATE nihil.error nihil.guard nihil.monad)
+
+target_sources(nihil.posix
+ PUBLIC FILE_SET modules TYPE CXX_MODULES FILES
+ nihil.posix.ccm
+ argv.ccm
+ ensure_dir.ccm
+ exec.ccm
+ fd.ccm
+ open.ccm
+ process.ccm
+ read_file.ccm
+ rename.ccm
+ spawn.ccm
+ write_file.ccm
+
+ PRIVATE
+ argv.cc
+ ensure_dir.cc
+ exec.cc
+ getenv.cc
+ fd.cc
+ find_in_path.cc
+ open.cc
+ process.cc
+ rename.cc
+)
+
+if(NIHIL_TESTS)
+ enable_testing()
+
+ add_executable(nihil.posix.test
+ test_fd.cc
+ test_getenv.cc
+ test_spawn.cc
+ )
+
+ target_link_libraries(nihil.posix.test PRIVATE
+ nihil.posix
+ Catch2::Catch2WithMain
+ )
+
+ find_package(Catch2 REQUIRED)
+
+ include(CTest)
+ include(Catch)
+ catch_discover_tests(nihil.posix.test)
+endif()
diff --git a/nihil/argv.cc b/nihil.posix/argv.cc
index f38293f..e6b1389 100644
--- a/nihil/argv.cc
+++ b/nihil.posix/argv.cc
@@ -9,7 +9,7 @@ module;
#include <string>
#include <vector>
-module nihil;
+module nihil.posix;
namespace nihil {
diff --git a/nihil/argv.ccm b/nihil.posix/argv.ccm
index b5d6d6a..6f60f4b 100644
--- a/nihil/argv.ccm
+++ b/nihil.posix/argv.ccm
@@ -9,7 +9,7 @@ module;
#include <string>
#include <vector>
-export module nihil:argv;
+export module nihil.posix:argv;
namespace nihil {
diff --git a/nihil/ensure_dir.cc b/nihil.posix/ensure_dir.cc
index f20d328..88e8898 100644
--- a/nihil/ensure_dir.cc
+++ b/nihil.posix/ensure_dir.cc
@@ -9,7 +9,9 @@ module;
#include <format>
#include <system_error>
-module nihil;
+module nihil.posix;
+
+import nihil.error;
namespace nihil {
diff --git a/nihil/ensure_dir.ccm b/nihil.posix/ensure_dir.ccm
index af2c4c7..fa92a90 100644
--- a/nihil/ensure_dir.ccm
+++ b/nihil.posix/ensure_dir.ccm
@@ -7,9 +7,9 @@ module;
#include <expected>
#include <filesystem>
-export module nihil:ensure_dir;
+export module nihil.posix:ensure_dir;
-import :error;
+import nihil.error;
namespace nihil {
diff --git a/nihil/exec.cc b/nihil.posix/exec.cc
index 6a7d614..5bdcbf7 100644
--- a/nihil/exec.cc
+++ b/nihil.posix/exec.cc
@@ -16,7 +16,10 @@ module;
extern char **environ;
-module nihil;
+module nihil.posix;
+
+import nihil.error;
+import nihil.monad;
namespace nihil {
@@ -40,7 +43,7 @@ auto fexecv::operator=(this fexecv &, fexecv &&) noexcept -> fexecv& = default;
auto execv(std::string_view path, argv &&argv)
-> std::expected<fexecv, error>
{
- auto file = co_await open_file(path, O_EXEC)
+ auto file = co_await open(path, O_EXEC)
.transform_error([&] (error cause) {
return error(std::format("could not open {}", path),
std::move(cause));
diff --git a/nihil/exec.ccm b/nihil.posix/exec.ccm
index 5c72dfe..6098318 100644
--- a/nihil/exec.ccm
+++ b/nihil.posix/exec.ccm
@@ -11,12 +11,11 @@ module;
#include <expected>
#include <string>
-export module nihil:exec;
+export module nihil.posix:exec;
+import nihil.error;
import :argv;
-import :error;
import :fd;
-import :find_in_path;
namespace nihil {
diff --git a/nihil/fd.cc b/nihil.posix/fd.cc
index 066056f..6d5e54f 100644
--- a/nihil/fd.cc
+++ b/nihil.posix/fd.cc
@@ -13,7 +13,10 @@ module;
#include <stdexcept>
#include <system_error>
-module nihil;
+module nihil.posix;
+
+import nihil.error;
+import nihil.monad;
namespace nihil {
diff --git a/nihil/fd.ccm b/nihil.posix/fd.ccm
index 3349fbd..b937f46 100644
--- a/nihil/fd.ccm
+++ b/nihil.posix/fd.ccm
@@ -11,9 +11,10 @@ module;
#include <stdexcept>
#include <system_error>
-export module nihil:fd;
+export module nihil.posix:fd;
-import :error;
+import nihil.error;
+import nihil.monad;
namespace nihil {
diff --git a/nihil/find_in_path.cc b/nihil.posix/find_in_path.cc
index 2b8a57c..6be963c 100644
--- a/nihil/find_in_path.cc
+++ b/nihil.posix/find_in_path.cc
@@ -12,19 +12,19 @@ module;
#include <fcntl.h>
#include <paths.h>
-module nihil;
+module nihil.posix;
namespace nihil {
auto find_in_path(std::filesystem::path const &file)
--> std::optional<fd>
+ -> std::optional<fd>
{
using namespace std::literals;
auto try_open =
[](std::filesystem::path const &file) -> std::optional<fd>
{
- auto ret = open_file(file, O_EXEC);
+ auto ret = open(file, O_EXEC);
if (ret)
return {std::move(*ret)};
return {};
@@ -49,4 +49,4 @@ auto find_in_path(std::filesystem::path const &file)
return {};
}
-} // namespace lfjail
+} // namespace nihil
diff --git a/nihil/getenv.cc b/nihil.posix/getenv.cc
index 3799d09..36df950 100644
--- a/nihil/getenv.cc
+++ b/nihil.posix/getenv.cc
@@ -13,7 +13,9 @@ module;
#include <unistd.h>
-module nihil;
+module nihil.posix;
+
+import nihil.error;
namespace nihil {
diff --git a/nihil.posix/nihil.posix.ccm b/nihil.posix/nihil.posix.ccm
new file mode 100644
index 0000000..9baecf8
--- /dev/null
+++ b/nihil.posix/nihil.posix.ccm
@@ -0,0 +1,45 @@
+/*
+ * This source code is released into the public domain.
+ */
+
+module;
+
+#include <expected>
+#include <filesystem>
+#include <optional>
+#include <string>
+
+export module nihil.posix;
+
+import nihil.error;
+
+export import :argv;
+export import :ensure_dir;
+export import :exec;
+export import :fd;
+export import :open;
+export import :process;
+export import :read_file;
+export import :rename;
+export import :spawn;
+export import :write_file;
+
+export namespace nihil {
+
+/*
+ * Find a variable by the given name in the environment by calling getenv_r().
+ */
+
+[[nodiscard]] auto getenv(std::string_view varname)
+ -> std::expected<std::string, error>;
+
+
+/*
+ * Find an executable in $PATH, open it with O_EXEC and return the fd.
+ * If $PATH is not set, uses _PATH_DEFPATH. If the file can't be found
+ * or opened, returns std::nullopt.
+ */
+[[nodiscard]] auto find_in_path(std::filesystem::path const &file)
+ -> std::optional<fd>;
+
+} // namespace nihil
diff --git a/nihil/open_file.cc b/nihil.posix/open.cc
index 49a3930..9ef6538 100644
--- a/nihil/open_file.cc
+++ b/nihil.posix/open.cc
@@ -11,11 +11,14 @@ module;
#include <fcntl.h>
#include <unistd.h>
-module nihil;
+module nihil.posix;
+
+import nihil.error;
+import :fd;
namespace nihil {
-auto open_file(std::filesystem::path const &filename, int flags, int mode)
+auto open(std::filesystem::path const &filename, int flags, int mode)
-> std::expected<fd, error>
{
auto fdno = ::open(filename.c_str(), flags, mode);
diff --git a/nihil/open_file.ccm b/nihil.posix/open.ccm
index 1333785..eaedacd 100644
--- a/nihil/open_file.ccm
+++ b/nihil.posix/open.ccm
@@ -6,20 +6,19 @@ module;
#include <expected>
#include <filesystem>
-#include <system_error>
-export module nihil:open_file;
+export module nihil.posix:open;
-import :error;
+import nihil.error;
import :fd;
-namespace nihil {
+export namespace nihil {
/*
* Open the given file and return an fd for it.
*/
-export [[nodiscard]] auto open_file(std::filesystem::path const &filename,
- int flags, int mode = 0777)
+[[nodiscard]] auto open(std::filesystem::path const &filename,
+ int flags, int mode = 0777)
-> std::expected<fd, error>;
} // namespace nihil
diff --git a/nihil/process.cc b/nihil.posix/process.cc
index 5cfe79e..70e84b7 100644
--- a/nihil/process.cc
+++ b/nihil.posix/process.cc
@@ -15,7 +15,9 @@ module;
#include <sys/types.h>
#include <sys/wait.h>
-module nihil;
+module nihil.posix;
+
+import nihil.error;
namespace nihil {
diff --git a/nihil/process.ccm b/nihil.posix/process.ccm
index 6d74513..425deac 100644
--- a/nihil/process.ccm
+++ b/nihil.posix/process.ccm
@@ -11,9 +11,9 @@ module;
#include <sys/types.h>
-export module nihil:process;
+export module nihil.posix:process;
-import :error;
+import nihil.error;
namespace nihil {
diff --git a/nihil/read_file.ccm b/nihil.posix/read_file.ccm
index cc93f7e..c950f67 100644
--- a/nihil/read_file.ccm
+++ b/nihil.posix/read_file.ccm
@@ -14,12 +14,12 @@ module;
#include <fcntl.h>
#include <unistd.h>
-export module nihil:read_file;
+export module nihil.posix:read_file;
-import :error;
+import nihil.error;
+import nihil.monad;
import :fd;
-import :monad;
-import :open_file;
+import :open;
namespace nihil {
@@ -31,7 +31,7 @@ read_file(std::filesystem::path const &filename,
std::output_iterator<char> auto &&iter)
-> std::expected<void, error>
{
- auto file = co_await open_file(filename, O_RDONLY);
+ auto file = co_await open(filename, O_RDONLY);
auto constexpr bufsize = std::size_t{1024};
auto buffer = std::array<char, bufsize>{};
diff --git a/nihil/rename_file.cc b/nihil.posix/rename.cc
index c712e44..9203d08 100644
--- a/nihil/rename_file.cc
+++ b/nihil.posix/rename.cc
@@ -7,7 +7,9 @@ module;
#include <expected>
#include <filesystem>
-module nihil;
+module nihil.posix;
+
+import nihil.error;
namespace nihil {
diff --git a/nihil/rename_file.ccm b/nihil.posix/rename.ccm
index 4abe975..796ec5b 100644
--- a/nihil/rename_file.ccm
+++ b/nihil.posix/rename.ccm
@@ -7,9 +7,9 @@ module;
#include <expected>
#include <filesystem>
-export module nihil:rename_file;
+export module nihil.posix:rename;
-import :error;
+import nihil.error;
namespace nihil {
@@ -17,8 +17,7 @@ namespace nihil {
* Rename a file (or directory).
*/
export [[nodiscard]] auto
-rename_file(std::filesystem::path const &oldp,
- std::filesystem::path const &newp)
+rename(std::filesystem::path const &oldp, std::filesystem::path const &newp)
-> std::expected<void, error>;
} // namespace nihil
diff --git a/nihil/spawn.ccm b/nihil.posix/spawn.ccm
index c15ab8d..5812716 100644
--- a/nihil/spawn.ccm
+++ b/nihil.posix/spawn.ccm
@@ -25,13 +25,12 @@ module;
#include <fcntl.h>
#include <unistd.h>
-export module nihil:spawn;
+export module nihil.posix:spawn;
+import nihil.monad;
import :argv;
import :exec;
-import :fd;
-import :monad;
-import :open_file;
+import :open;
import :process;
namespace nihil {
@@ -130,7 +129,7 @@ make_fd_file(int fdno, std::filesystem::path const &file,
int flags, int mode = 0777)
-> std::expected<fd_file, error>
{
- auto fd = co_await open_file(file, flags, mode);
+ auto fd = co_await open(file, flags, mode);
co_return fd_file(fdno, std::move(fd));
}
diff --git a/nihil/tests/fd.cc b/nihil.posix/test_fd.cc
index 59054fa..8dff323 100644
--- a/nihil/tests/fd.cc
+++ b/nihil.posix/test_fd.cc
@@ -10,7 +10,8 @@
#include <catch2/catch_test_macros.hpp>
-import nihil;
+import nihil.error;
+import nihil.posix;
using namespace std::literals;
diff --git a/nihil/tests/getenv.cc b/nihil.posix/test_getenv.cc
index adfa84f..fdb5277 100644
--- a/nihil/tests/getenv.cc
+++ b/nihil.posix/test_getenv.cc
@@ -4,16 +4,17 @@
#include <ranges>
#include <string>
+#include <system_error>
#include <unistd.h>
#include <catch2/catch_test_macros.hpp>
-import nihil;
+import nihil.posix;
TEST_CASE("getenv: existing value", "[getenv]")
{
- auto constexpr *name = "LFJAIL_TEST_VAR";
+ auto constexpr *name = "NIHIL_TEST_VAR";
auto constexpr *value = "test is a test";
REQUIRE(::setenv(name, value, 1) == 0);
@@ -25,7 +26,7 @@ TEST_CASE("getenv: existing value", "[getenv]")
TEST_CASE("getenv: non-existing value", "[getenv]")
{
- auto constexpr *name = "LFJAIL_TEST_VAR";
+ auto constexpr *name = "NIHIL_TEST_VAR";
REQUIRE(::unsetenv(name) == 0);
@@ -37,7 +38,7 @@ TEST_CASE("getenv: non-existing value", "[getenv]")
// Force the call to getenv_r() to reallocate.
TEST_CASE("getenv: long value")
{
- auto constexpr *name = "LFJAIL_TEST_VAR";
+ auto constexpr *name = "NIHIL_TEST_VAR";
auto const value = std::string(4096, 'a');
REQUIRE(::setenv(name, value.c_str(), 1) == 0);
diff --git a/nihil/tests/spawn.cc b/nihil.posix/test_spawn.cc
index 2821fb6..da321ff 100644
--- a/nihil/tests/spawn.cc
+++ b/nihil.posix/test_spawn.cc
@@ -4,7 +4,7 @@
#include <catch2/catch_test_macros.hpp>
-import nihil;
+import nihil.posix;
TEST_CASE("spawn: system", "[spawn]")
{
diff --git a/nihil/write_file.ccm b/nihil.posix/write_file.ccm
index 6722d5f..867e0db 100644
--- a/nihil/write_file.ccm
+++ b/nihil.posix/write_file.ccm
@@ -14,13 +14,14 @@ module;
#include <fcntl.h>
#include <unistd.h>
-export module nihil:write_file;
+export module nihil.posix:write_file;
-import :error;
-import :guard;
-import :monad;
-import :open_file;
-import :rename_file;
+import nihil.error;
+import nihil.guard;
+import nihil.monad;
+import :fd;
+import :open;
+import :rename;
namespace nihil {
@@ -34,7 +35,7 @@ auto write_file(std::filesystem::path const &filename,
int mode = 0777)
-> std::expected<std::size_t, error>
{
- auto file = co_await open_file(filename, O_CREAT|O_WRONLY, mode);
+ auto file = co_await open(filename, O_CREAT|O_WRONLY, mode);
auto nbytes = co_await write(file, range);
co_return nbytes;
}
@@ -71,7 +72,7 @@ auto safe_write_file(std::filesystem::path const &filename,
});
co_await write_file(tmpfile, range);
- co_await rename_file(tmpfile, filename);
+ co_await nihil::rename(tmpfile, filename);
tmpfile_guard.release();
co_return {};
diff --git a/nihil.ucl/CMakeLists.txt b/nihil.ucl/CMakeLists.txt
index df13e84..9d8ab3a 100644
--- a/nihil.ucl/CMakeLists.txt
+++ b/nihil.ucl/CMakeLists.txt
@@ -3,7 +3,7 @@
pkg_check_modules(LIBUCL REQUIRED libucl)
add_library(nihil.ucl STATIC)
-target_link_libraries(nihil.ucl PUBLIC nihil)
+target_link_libraries(nihil.ucl PRIVATE nihil.error nihil.monad)
target_sources(nihil.ucl
PUBLIC FILE_SET modules TYPE CXX_MODULES FILES
diff --git a/nihil.ucl/boolean.cc b/nihil.ucl/boolean.cc
index 2a643b9..91f2b17 100644
--- a/nihil.ucl/boolean.cc
+++ b/nihil.ucl/boolean.cc
@@ -13,7 +13,7 @@ module;
module nihil.ucl;
-import nihil;
+import nihil.error;
namespace nihil::ucl {
diff --git a/nihil.ucl/errc.cc b/nihil.ucl/errc.cc
index fc1d9f8..0b65b86 100644
--- a/nihil.ucl/errc.cc
+++ b/nihil.ucl/errc.cc
@@ -9,8 +9,6 @@ module;
module nihil.ucl;
-import nihil;
-
namespace nihil::ucl {
struct ucl_error_category final : std::error_category {
diff --git a/nihil.ucl/integer.cc b/nihil.ucl/integer.cc
index f4f08ef..825d8f6 100644
--- a/nihil.ucl/integer.cc
+++ b/nihil.ucl/integer.cc
@@ -13,7 +13,7 @@ module;
module nihil.ucl;
-import nihil;
+import nihil.error;
namespace nihil::ucl {
diff --git a/nihil.ucl/integer.ccm b/nihil.ucl/integer.ccm
index d5ac72a..0ea490c 100644
--- a/nihil.ucl/integer.ccm
+++ b/nihil.ucl/integer.ccm
@@ -15,7 +15,6 @@ module;
export module nihil.ucl:integer;
-import nihil;
import :object;
import :type;
diff --git a/nihil.ucl/object.cc b/nihil.ucl/object.cc
index ee4968b..9a150fb 100644
--- a/nihil.ucl/object.cc
+++ b/nihil.ucl/object.cc
@@ -12,8 +12,6 @@ module;
module nihil.ucl;
-import nihil;
-
namespace nihil::ucl {
object::object(ref_t, ::ucl_object_t const *object)
diff --git a/nihil.ucl/object.ccm b/nihil.ucl/object.ccm
index 40f2088..dffb54e 100644
--- a/nihil.ucl/object.ccm
+++ b/nihil.ucl/object.ccm
@@ -18,7 +18,6 @@ module;
export module nihil.ucl:object;
-import nihil;
import :type;
namespace nihil::ucl {
diff --git a/nihil.ucl/object_cast.ccm b/nihil.ucl/object_cast.ccm
index 07588a1..3fa9eba 100644
--- a/nihil.ucl/object_cast.ccm
+++ b/nihil.ucl/object_cast.ccm
@@ -12,7 +12,7 @@ module;
export module nihil.ucl:object_cast;
-import nihil;
+import nihil.monad;
import :type;
import :object;
import :array;
diff --git a/nihil.ucl/parser.cc b/nihil.ucl/parser.cc
index 2288c4c..0a08670 100644
--- a/nihil.ucl/parser.cc
+++ b/nihil.ucl/parser.cc
@@ -12,7 +12,7 @@ module;
module nihil.ucl;
-import nihil;
+import nihil.error;
namespace nihil::ucl {
diff --git a/nihil.ucl/parser.ccm b/nihil.ucl/parser.ccm
index 2630c81..20e5c66 100644
--- a/nihil.ucl/parser.ccm
+++ b/nihil.ucl/parser.ccm
@@ -16,7 +16,7 @@ module;
export module nihil.ucl:parser;
-import nihil;
+import nihil.monad;
import :object;
import :map;
diff --git a/nihil.ucl/real.cc b/nihil.ucl/real.cc
index b3d50c3..6d9e082 100644
--- a/nihil.ucl/real.cc
+++ b/nihil.ucl/real.cc
@@ -15,7 +15,7 @@ module;
module nihil.ucl;
-import nihil;
+import nihil.error;
namespace nihil::ucl {
diff --git a/nihil.ucl/string.cc b/nihil.ucl/string.cc
index 0fc9808..67e97f4 100644
--- a/nihil.ucl/string.cc
+++ b/nihil.ucl/string.cc
@@ -14,7 +14,7 @@ module;
module nihil.ucl;
-import nihil;
+import nihil.error;
namespace nihil::ucl {
diff --git a/nihil.ucl/string.ccm b/nihil.ucl/string.ccm
index 9127b2d..c757bf1 100644
--- a/nihil.ucl/string.ccm
+++ b/nihil.ucl/string.ccm
@@ -14,7 +14,6 @@ module;
export module nihil.ucl:string;
-import nihil;
import :object;
import :type;
diff --git a/nihil.ucl/tests/CMakeLists.txt b/nihil.ucl/tests/CMakeLists.txt
index 93559a7..0257b4f 100644
--- a/nihil.ucl/tests/CMakeLists.txt
+++ b/nihil.ucl/tests/CMakeLists.txt
@@ -13,9 +13,7 @@ add_executable(nihil.ucl.test
string.cc
)
-target_link_libraries(nihil.ucl.test PRIVATE
- nihil nihil.ucl
- Catch2::Catch2WithMain)
+target_link_libraries(nihil.ucl.test PRIVATE nihil.ucl Catch2::Catch2WithMain)
find_package(Catch2 REQUIRED)
diff --git a/nihil.ucl/tests/array.cc b/nihil.ucl/tests/array.cc
index 37928aa..866fa45 100644
--- a/nihil.ucl/tests/array.cc
+++ b/nihil.ucl/tests/array.cc
@@ -11,7 +11,6 @@
#include <catch2/catch_test_macros.hpp>
#include <ucl.h>
-import nihil;
import nihil.ucl;
TEST_CASE("ucl: array: invariants", "[ucl]")
diff --git a/nihil.ucl/tests/emit.cc b/nihil.ucl/tests/emit.cc
index d75255b..a7dcd71 100644
--- a/nihil.ucl/tests/emit.cc
+++ b/nihil.ucl/tests/emit.cc
@@ -7,7 +7,6 @@
#include <catch2/catch_test_macros.hpp>
-import nihil;
import nihil.ucl;
TEST_CASE("ucl: emit to std::ostream", "[ucl]")
diff --git a/nihil.ucl/tests/parse.cc b/nihil.ucl/tests/parse.cc
index c56974e..43ce219 100644
--- a/nihil.ucl/tests/parse.cc
+++ b/nihil.ucl/tests/parse.cc
@@ -7,7 +7,6 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
-import nihil;
import nihil.ucl;
TEST_CASE("ucl parse: iterate array", "[ucl]")
diff --git a/nihil.ucl/type.ccm b/nihil.ucl/type.ccm
index cd98c01..f3b3aef 100644
--- a/nihil.ucl/type.ccm
+++ b/nihil.ucl/type.ccm
@@ -13,7 +13,7 @@ module;
export module nihil.ucl:type;
-import nihil;
+import nihil.error;
namespace nihil::ucl {
diff --git a/nihil.util/CMakeLists.txt b/nihil.util/CMakeLists.txt
new file mode 100644
index 0000000..b809a68
--- /dev/null
+++ b/nihil.util/CMakeLists.txt
@@ -0,0 +1,36 @@
+# This source code is released into the public domain.
+
+add_library(nihil.util STATIC)
+target_link_libraries(nihil.util PRIVATE nihil.core nihil.error nihil.monad)
+target_sources(nihil.util
+ PUBLIC FILE_SET modules TYPE CXX_MODULES FILES
+ nihil.util.ccm
+
+ ctype.ccm
+ parse_size.ccm
+ next_word.ccm
+ skipws.ccm
+ tabulate.ccm
+)
+
+if(NIHIL_TESTS)
+ enable_testing()
+
+ add_executable(nihil.util.test
+ test_ctype.cc
+ test_parse_size.cc
+ test_next_word.cc
+ test_skipws.cc
+ test_tabulate.cc
+ )
+ target_link_libraries(nihil.util.test PRIVATE
+ nihil.util
+ Catch2::Catch2WithMain
+ )
+
+ find_package(Catch2 REQUIRED)
+
+ include(CTest)
+ include(Catch)
+ catch_discover_tests(nihil.util.test)
+endif()
diff --git a/nihil/ctype.ccm b/nihil.util/ctype.ccm
index 5f45703..6d30c4f 100644
--- a/nihil/ctype.ccm
+++ b/nihil.util/ctype.ccm
@@ -7,7 +7,7 @@ module;
#include <concepts>
#include <locale>
-export module nihil:ctype;
+export module nihil.util:ctype;
namespace nihil {
diff --git a/nihil/next_word.ccm b/nihil.util/next_word.ccm
index 6c988a0..c5d3ad7 100644
--- a/nihil/next_word.ccm
+++ b/nihil.util/next_word.ccm
@@ -10,9 +10,8 @@ module;
#include <string>
#include <utility>
-export module nihil:next_word;
+export module nihil.util:next_word;
-import :ctype;
import :skipws;
namespace nihil {
diff --git a/nihil.util/nihil.util.ccm b/nihil.util/nihil.util.ccm
new file mode 100644
index 0000000..afd513a
--- /dev/null
+++ b/nihil.util/nihil.util.ccm
@@ -0,0 +1,13 @@
+/*
+ * This source code is released into the public domain.
+ */
+
+module;
+
+export module nihil.util;
+
+export import :ctype;
+export import :parse_size;
+export import :next_word;
+export import :skipws;
+export import :tabulate;
diff --git a/nihil/parse_size.ccm b/nihil.util/parse_size.ccm
index a449431..c692578 100644
--- a/nihil/parse_size.ccm
+++ b/nihil.util/parse_size.ccm
@@ -13,11 +13,13 @@ module;
#include <system_error>
#include <utility>
-export module nihil:parse_size;
+export module nihil.util:parse_size;
+
+import nihil.core;
+import nihil.error;
+import nihil.monad;
import :ctype;
-import :errc;
-import :error;
namespace nihil {
diff --git a/nihil/skipws.ccm b/nihil.util/skipws.ccm
index 3d760a9..4813ae8 100644
--- a/nihil/skipws.ccm
+++ b/nihil.util/skipws.ccm
@@ -9,7 +9,7 @@ module;
#include <ranges>
#include <string>
-export module nihil:skipws;
+export module nihil.util:skipws;
import :ctype;
diff --git a/nihil/tabulate.ccm b/nihil.util/tabulate.ccm
index 9faf885..5998b24 100644
--- a/nihil/tabulate.ccm
+++ b/nihil.util/tabulate.ccm
@@ -11,10 +11,10 @@ module;
#include <iterator>
#include <vector>
-export module nihil:tabulate;
+export module nihil.util:tabulate;
+import nihil.error;
import :ctype;
-import :error;
namespace nihil {
diff --git a/nihil/tests/ctype.cc b/nihil.util/test_ctype.cc
index 87f5103..62721d1 100644
--- a/nihil/tests/ctype.cc
+++ b/nihil.util/test_ctype.cc
@@ -4,7 +4,7 @@
#include <catch2/catch_test_macros.hpp>
-import nihil;
+import nihil.util;
TEST_CASE("ctype: space", "[ctype]") {
auto is_utf8_space =
diff --git a/nihil/tests/next_word.cc b/nihil.util/test_next_word.cc
index 4055485..7e61237 100644
--- a/nihil/tests/next_word.cc
+++ b/nihil.util/test_next_word.cc
@@ -7,7 +7,7 @@
#include <catch2/catch_test_macros.hpp>
-import nihil;
+import nihil.util;
TEST_CASE("next_word: basic", "[next_word]")
{
diff --git a/nihil/tests/parse_size.cc b/nihil.util/test_parse_size.cc
index fb8188d..4f4d018 100644
--- a/nihil/tests/parse_size.cc
+++ b/nihil.util/test_parse_size.cc
@@ -7,7 +7,8 @@
#include <catch2/catch_test_macros.hpp>
-import nihil;
+import nihil.core;
+import nihil.util;
TEST_CASE("parse_size: empty value", "[nihil]")
{
diff --git a/nihil/tests/skipws.cc b/nihil.util/test_skipws.cc
index 2159e2e..837c1f3 100644
--- a/nihil/tests/skipws.cc
+++ b/nihil.util/test_skipws.cc
@@ -8,7 +8,7 @@ using namespace std::literals;
#include <catch2/catch_test_macros.hpp>
-import nihil;
+import nihil.util;
TEST_CASE("skipws: basic", "[skipws]")
{
diff --git a/nihil/tests/tabulate.cc b/nihil.util/test_tabulate.cc
index 84f8b33..8dee796 100644
--- a/nihil/tests/tabulate.cc
+++ b/nihil.util/test_tabulate.cc
@@ -8,7 +8,7 @@
#include <catch2/catch_test_macros.hpp>
-import nihil;
+import nihil.util;
using namespace std::literals;
using namespace nihil;
diff --git a/nihil/CMakeLists.txt b/nihil/CMakeLists.txt
deleted file mode 100644
index 64dbe6a..0000000
--- a/nihil/CMakeLists.txt
+++ /dev/null
@@ -1,52 +0,0 @@
-# This source code is released into the public domain.
-
-add_library(nihil STATIC)
-target_sources(nihil
- PUBLIC FILE_SET modules TYPE CXX_MODULES FILES
- nihil.ccm
- argv.ccm
- command_map.ccm
- ctype.ccm
- ensure_dir.ccm
- errc.ccm
- error.ccm
- exec.ccm
- fd.ccm
- find_in_path.ccm
- format_filesystem.ccm
- generator.ccm
- getenv.ccm
- guard.ccm
- match.ccm
- monad.ccm
- next_word.ccm
- open_file.ccm
- parse_size.ccm
- process.ccm
- read_file.ccm
- rename_file.ccm
- skipws.ccm
- spawn.ccm
- tabulate.ccm
- usage_error.ccm
- write_file.ccm
-
- PRIVATE
- argv.cc
- command_map.cc
- ensure_dir.cc
- errc.cc
- error.cc
- exec.cc
- fd.cc
- find_in_path.cc
- getenv.cc
- open_file.cc
- process.cc
- rename_file.cc
-)
-
-if(NIHIL_TESTS)
- add_subdirectory(tests)
- enable_testing()
-endif()
diff --git a/nihil/errc.cc b/nihil/errc.cc
deleted file mode 100644
index 1d4e6fa..0000000
--- a/nihil/errc.cc
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * This source code is released into the public domain.
- */
-
-module;
-
-#include <string>
-#include <system_error>
-
-module nihil;
-
-namespace nihil {
-
-struct nihil_error_category final : std::error_category {
- auto name() const noexcept -> char const * override;
- auto message(int err) const -> std::string override;
-};
-
-auto nihil_category() noexcept -> std::error_category &
-{
- static auto category = nihil_error_category();
- return category;
-}
-
-auto make_error_condition(errc ec) -> std::error_condition
-{
- return {static_cast<int>(ec), nihil_category()};
-}
-
-auto nihil_error_category::name() const noexcept -> char const *
-{
- return "nihil";
-}
-
-auto nihil_error_category::message(int err) const -> std::string
-{
- switch (static_cast<errc>(err)) {
- case errc::no_error:
- return "No error";
- case errc::empty_string:
- return "Empty string is not permitted";
- case errc::invalid_unit:
- return "Invalid unit specifier";
- default:
- return "Undefined error";
- }
-}
-
-} // namespace nihil
diff --git a/nihil/errc.ccm b/nihil/errc.ccm
deleted file mode 100644
index eb0389e..0000000
--- a/nihil/errc.ccm
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * This source code is released into the public domain.
- */
-
-module;
-
-#include <string>
-#include <system_error>
-
-export module nihil:errc;
-
-namespace nihil {
-
-export enum struct errc {
- no_error = 0,
-
- // Empty string is not allowed.
- empty_string,
-
- // Invalid unit, e.g. in parse_size()
- invalid_unit,
-};
-
-export auto nihil_category() noexcept -> std::error_category &;
-export auto make_error_condition(errc ec) -> std::error_condition;
-
-} // namespace nihil
-
-namespace std {
-
-export template<>
-struct is_error_condition_enum<nihil::errc> : true_type {};
-
-} // namespace std
diff --git a/nihil/find_in_path.ccm b/nihil/find_in_path.ccm
deleted file mode 100644
index 3983c40..0000000
--- a/nihil/find_in_path.ccm
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * This source code is released into the public domain.
- */
-
-module;
-
-#include <filesystem>
-#include <optional>
-
-export module nihil:find_in_path;
-
-import :fd;
-
-namespace nihil {
-
-/*
- * Find an executable in $PATH, open it with O_EXEC and return the fd.
- * If $PATH is not set, uses _PATH_DEFPATH. If the file can't be found
- * or opened, returns std::nullopt.
- */
-export [[nodiscard]] auto find_in_path(std::filesystem::path const &file)
- -> std::optional<fd>;
-
-} // namespace nihil
diff --git a/nihil/format_filesystem.ccm b/nihil/format_filesystem.ccm
deleted file mode 100644
index 11d8675..0000000
--- a/nihil/format_filesystem.ccm
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * This source code is released into the public domain.
- */
-
-module;
-
-#include <filesystem>
-#include <format>
-#include <ranges>
-
-export module nihil:format_filesystem;
-
-/*
- * std::formatter for path was only added in C++26; LLVM 19 doesn't have it.
- * This is a basic implementation that doesn't support any format flags.
- */
-
-#ifndef __cpp_lib_format_path
-export template<>
-struct std::formatter<std::filesystem::path, char>
-{
- template<typename ParseContext>
- constexpr auto parse(ParseContext &ctx) -> ParseContext::iterator
- {
- return ctx.begin();
- }
-
- template<typename FmtContext>
- auto format(std::filesystem::path const &path, FmtContext& ctx) const
- -> FmtContext::iterator
- {
- return std::ranges::copy(path.native(), ctx.out()).out;
- }
-};
-#endif // !__cpp_lib_format_path
diff --git a/nihil/getenv.ccm b/nihil/getenv.ccm
deleted file mode 100644
index a7831e0..0000000
--- a/nihil/getenv.ccm
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * This source code is released into the public domain.
- */
-
-module;
-
-#include <expected>
-#include <string>
-#include <system_error>
-
-export module nihil:getenv;
-
-import :error;
-
-namespace nihil {
-
-/*
- * Find a variable by the given name in the environment by calling getenv_r().
- */
-
-export [[nodiscard]] auto getenv(std::string_view varname)
- -> std::expected<std::string, error>;
-
-} // namespace nihil
diff --git a/nihil/nihil.ccm b/nihil/nihil.ccm
deleted file mode 100644
index cbcadaf..0000000
--- a/nihil/nihil.ccm
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * This source code is released into the public domain.
- */
-
-module;
-
-export module nihil;
-
-export import :argv;
-export import :command_map;
-export import :ctype;
-export import :ensure_dir;
-export import :errc;
-export import :error;
-export import :exec;
-export import :fd;
-export import :find_in_path;
-export import :format_filesystem;
-export import :generator;
-export import :getenv;
-export import :guard;
-export import :match;
-export import :monad;
-export import :next_word;
-export import :open_file;
-export import :parse_size;
-export import :process;
-export import :read_file;
-export import :rename_file;
-export import :skipws;
-export import :spawn;
-export import :tabulate;
-export import :usage_error;
-export import :write_file;
diff --git a/nihil/tests/CMakeLists.txt b/nihil/tests/CMakeLists.txt
deleted file mode 100644
index dd2d376..0000000
--- a/nihil/tests/CMakeLists.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-# This source code is released into the public domain.
-
-add_executable(nihil.test
- command_map.cc
- ctype.cc
- error.cc
- fd.cc
- generator.cc
- getenv.cc
- guard.cc
- monad.cc
- next_word.cc
- parse_size.cc
- skipws.cc
- spawn.cc
- tabulate.cc
-)
-
-target_link_libraries(nihil.test PRIVATE
- nihil
- Catch2::Catch2WithMain
-)
-
-find_package(Catch2 REQUIRED)
-
-include(CTest)
-include(Catch)
-catch_discover_tests(nihil.test)