diff options
author | flu0r1ne <flu0r1ne@flu0r1ne.net> | 2023-09-12 15:58:43 -0500 |
---|---|---|
committer | flu0r1ne <flu0r1ne@flu0r1ne.net> | 2023-09-12 15:58:43 -0500 |
commit | 326076c46cbdc7afc9bcc2df56aa0b95d174f927 (patch) | |
tree | 42966f0624675aa5abf8f29096787a3cc171ba60 /src | |
parent | ea718c0997cd2e61c2a7fb491d1e7479296e710f (diff) | |
download | wg2nd-326076c46cbdc7afc9bcc2df56aa0b95d174f927.tar.xz wg2nd-326076c46cbdc7afc9bcc2df56aa0b95d174f927.zip |
Add version subcommandv0.1.0
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 10 | ||||
-rw-r--r-- | src/version.hpp | 3 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp index a5dbf8b..e685e10 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,6 +4,8 @@ * Copyright (C) 2023 Alex David <flu0r1ne@flu0r1ne.net> */ +#include "version.hpp" + #include <iostream> #include <string> #include <vector> @@ -94,12 +96,14 @@ constexpr char const * DEFAULT_OUTPUT_PATH = "/etc/systemd/network/"; */ void die_usage(const char *prog) { - err("Usage: %s { install, generate } [ OPTIONS ] { -h, CONFIG_FILE }", prog); + err("Usage: %s { install, generate } [ OPTIONS ] { -h, CONFIG_FILE }", prog); + err("Usage: %s version", prog); die("Use -h for help"); } void print_help(const char *prog) { - err("Usage: %s { install, generate } [ OPTIONS ] { -h, CONFIG_FILE }\n", prog); + err("Usage: %s { install, generate } [ OPTIONS ] { -h, CONFIG_FILE }", prog); + err("Usage: %s version\n", prog); err(" CONFIG_FILE is the complete path to a WireGuard configuration file, used by"); err(" `wg-quick`. `wg2nd` will convert the WireGuard configuration to networkd"); err(" files.\n"); @@ -437,6 +441,8 @@ int main(int argc, char **argv) { return wg2nd_generate(prog, argc - 1, argv + 1); } else if (action == "install") { return wg2nd_install(prog, argc - 1, argv + 1); + } else if (action == "version") { + printf("%s\n", VERSION); } else if (action == "-h" || action == "--help") { print_help(prog); } else { diff --git a/src/version.hpp b/src/version.hpp new file mode 100644 index 0000000..3e8675e --- /dev/null +++ b/src/version.hpp @@ -0,0 +1,3 @@ +#pragma once + +constexpr char const * VERSION = "v0.1.0"; |