summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-06-24 20:33:48 -1000
committerFuwn <[email protected]>2022-06-24 20:33:48 -1000
commitcfa6b082eaa4a02f34576cbd5a55e3c46f04acdd (patch)
tree01fc32af55077dcf7093b904a9208125bb197874 /src
parentfix(node): stringable explicit copy constructor (diff)
downloadcait-cfa6b082eaa4a02f34576cbd5a55e3c46f04acdd.tar.xz
cait-cfa6b082eaa4a02f34576cbd5a55e3c46f04acdd.zip
refactor(help): move version to constexpr
Diffstat (limited to 'src')
-rw-r--r--src/cli.cc2
-rw-r--r--src/help.cc30
-rw-r--r--src/help.hh17
3 files changed, 37 insertions, 12 deletions
diff --git a/src/cli.cc b/src/cli.cc
index b1f4eb4..573b9a9 100644
--- a/src/cli.cc
+++ b/src/cli.cc
@@ -72,7 +72,7 @@ auto cli::look() -> int {
std::cout << cait::help_message() << '\n';
} break;
case cait::utility::hash("--version"): {
- std::cout << VERSION << '\n';
+ std::cout << version::whole() << '\n';
} break;
default: {
std::string cait_file_name = this->option("-f")->value_or("build.cait");
diff --git a/src/help.cc b/src/help.cc
index 18853e1..2271e9f 100644
--- a/src/help.cc
+++ b/src/help.cc
@@ -32,13 +32,29 @@ auto help_message() -> std::string {
"manual).\n"
"\n"
"options:\n"
- " --version print cait version (\"" VERSION "\")\n"
- " -v, --verbose show all command lines while building\n"
- "\n"
- " -C DIR change to DIR before doing anything else\n"
- " -f FILE specify input build file [default=build.cait]\n"
- "\n"
- " -j N run N jobs in parallel (0 means infinity) [default="
+ " --version print cait version (\"" +
+ version::whole() +
+ "\")\n"
+ " -v, --verbose "
+ "show all command "
+ "lines while "
+ "building\n"
+ "\n"
+ " -C DIR "
+ "change to DIR "
+ "before doing "
+ "anything else\n"
+ " -f FILE "
+ "specify input "
+ "build file "
+ "[default=build."
+ "cait]\n"
+ "\n"
+ " -j N run N "
+ "jobs in parallel "
+ "(0 means "
+ "infinity) "
+ "[default="
<< std::thread::hardware_concurrency() + 2
<< " on this system]\n"
" -k N keep going until N jobs fail (0 means infinity) "
diff --git a/src/help.hh b/src/help.hh
index 37afb58..88517da 100644
--- a/src/help.hh
+++ b/src/help.hh
@@ -21,13 +21,22 @@
#include <sstream>
-#define VERSION_MAJOR "0"
-#define VERSION_MINOR "1"
-#define VERSION_PATCH "0"
-#define VERSION VERSION_MAJOR "." VERSION_MINOR "." VERSION_PATCH
+#define CAIT_TO_STRING(x) #x
+#define CAIT_STR(x) CAIT_TO_STRING(x)
namespace cait {
+namespace version {
+
+constexpr unsigned int major = 0;
+constexpr unsigned int minor = 1;
+constexpr unsigned int patch = 0;
+constexpr auto whole() -> std::string {
+ return CAIT_STR(major) "." CAIT_STR(minor) "." CAIT_STR(patch);
+}
+
+} // namespace version
+
auto help_message() -> std::string;
} // namespace cait