summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZuhaitz <zuhaitz.zechhub@gmail.com>2026-01-15 00:09:49 +0000
committerGitHub <noreply@github.com>2026-01-15 00:09:49 +0000
commit1ad1a58b4db0634578d23672a558d6ae6502d588 (patch)
treeba0fe32e572a255c20ec512d0eb7b0d4eff545db /src
parentdcfdc053cb5f9fb4d5eac0a2233c75126b7a8188 (diff)
parent3ca9dc2dd4601ab1411f09a813aabb3a0b71fcfb (diff)
Merge pull request #49 from pepedinho/cli-version-flag
Add `--version` / `-V` flag to zc CLI
Diffstat (limited to 'src')
-rw-r--r--src/main.c11
-rw-r--r--src/zprep.h3
2 files changed, 14 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 580b555..49691ea 100644
--- a/src/main.c
+++ b/src/main.c
@@ -21,6 +21,11 @@ void print_search_paths()
printf(" /usr/share/zenc\n");
}
+void print_version()
+{
+ printf("Zen C version %s\n", ZEN_VERSION);
+}
+
void print_usage()
{
printf("Usage: zc [command] [options] <file.zc>\n");
@@ -32,6 +37,7 @@ void print_usage()
printf(" transpile Transpile to C code only (no compilation)\n");
printf(" lsp Start Language Server\n");
printf("Options:\n");
+ printf(" --version Print version information");
printf(" -o <file> Output executable name\n");
printf(" --emit-c Keep generated C file (out.c)\n");
printf(" --freestanding Freestanding mode (no stdlib)\n");
@@ -119,6 +125,11 @@ int main(int argc, char **argv)
{
g_config.emit_c = 1;
}
+ else if (strcmp(arg, "--version") == 0|| strcmp(arg, "-V") == 0)
+ {
+ print_version();
+ return 0;
+ }
else if (strcmp(arg, "--verbose") == 0 || strcmp(arg, "-v") == 0)
{
g_config.verbose = 1;
diff --git a/src/zprep.h b/src/zprep.h
index 5c4ab4e..669169c 100644
--- a/src/zprep.h
+++ b/src/zprep.h
@@ -8,6 +8,9 @@
#include <stdlib.h>
#include <string.h>
+// **ZEN VERSION**
+#define ZEN_VERSION "0.1.0"
+
// ** ANSI COLORS **
#define COLOR_RESET "\033[0m"
#define COLOR_RED "\033[1;31m"