aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/cli.c8
-rw-r--r--src/std.h1
-rw-r--r--src/version.h6
-rw-r--r--tests/111.sh6
4 files changed, 21 insertions, 0 deletions
diff --git a/src/cli.c b/src/cli.c
index d4297aa..a55d17e 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -1,5 +1,10 @@
#include "cli.h"
#include "common.h"
+#include "version.h"
+
+static void print_version() {
+ printf("ducc v%s\n", DUCC_VERSION);
+}
CliArgs* parse_cli_args(int argc, char** argv) {
const char* output_filename = NULL;
@@ -29,6 +34,9 @@ CliArgs* parse_cli_args(int argc, char** argv) {
only_compile = TRUE;
} else if (strcmp(argv[i], "-MMD") == 0) {
generate_deps = TRUE;
+ } else if (strcmp(argv[i], "--version") == 0) {
+ print_version();
+ exit(0);
} else {
fatal_error("unknown option: %s", argv[i]);
}
diff --git a/src/std.h b/src/std.h
index 2b1ad4a..ad31747 100644
--- a/src/std.h
+++ b/src/std.h
@@ -26,6 +26,7 @@ void* memcpy(void*, const void*, size_t);
void* memmove(void*, const void*, size_t);
void* memset(void*, int, size_t);
int mkstemps(char*, int);
+int printf(const char*, ...);
void* realloc(void*, size_t);
int sprintf(char*, const char*, ...);
int strcmp(const char*, const char*);
diff --git a/src/version.h b/src/version.h
new file mode 100644
index 0000000..8f8b201
--- /dev/null
+++ b/src/version.h
@@ -0,0 +1,6 @@
+#ifndef DUCC_VERSION_H
+#define DUCC_VERSION_H
+
+#define DUCC_VERSION "0.1.0"
+
+#endif
diff --git a/tests/111.sh b/tests/111.sh
new file mode 100644
index 0000000..9f500fd
--- /dev/null
+++ b/tests/111.sh
@@ -0,0 +1,6 @@
+expected="ducc v0.1.0"
+
+if [[ "$("$ducc" --version)" != "$expected" ]]; then
+ echo "invalid output" >&2
+ exit 1
+fi