]> mj.ucw.cz Git - xsv.git/commitdiff
Added version number everywhere
authorMartin Mares <mj@ucw.cz>
Tue, 24 Jul 2012 16:55:53 +0000 (18:55 +0200)
committerMartin Mares <mj@ucw.cz>
Tue, 24 Jul 2012 16:55:53 +0000 (18:55 +0200)
Makefile
xsv.1.txt
xsv.c

index db742f48af1e2ebd55cddc96928812a1f5a86394..80eeeebfa885f1414998552e9df00a0f91f9c4c4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,9 @@
+VERSION=1.0
+
 PCRE_CFLAGS:=$(shell pcre-config --cflags)
 PCRE_LIBS:=$(shell pcre-config --libs)
 
-CFLAGS=-O2 -Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes -Wundef -Wredundant-decls -std=gnu99 $(PCRE_CFLAGS) -g
+CFLAGS=-O2 -Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes -Wundef -Wredundant-decls -std=gnu99 $(PCRE_CFLAGS) -DVERSION='"$(VERSION)"'
 LDLIBS=$(PCRE_LIBS)
 
 all: xsv xsv.1
@@ -10,7 +12,7 @@ tests: xsv
        ./run-tests
 
 xsv.1: xsv.1.txt
-       a2x -f manpage $<
+       a2x -f manpage -a xsvversion=$(VERSION) $<
 
 clean:
        rm -f `find . -name "*~" -or -name "*.[oa]" -or -name "\#*\#" -or -name TAGS -or -name core -or -name .depend -or -name .#*`
index 921febff8bb3bee0b05cde4727b2dff079f0acc1..e39252869650243a94b7d2e758d1c268ee12f6ce 100644 (file)
--- a/xsv.1.txt
+++ b/xsv.1.txt
@@ -1,7 +1,7 @@
 XSV(1)
 ======
 :man source: XSV
-:man version: 1.0
+:man version: {xsvversion}
 :man manual: The Swiss-Army Knife for CSV
 
 NAME
diff --git a/xsv.c b/xsv.c
index b11946c7c1b92aa47d91de00ddfccc453609199a..c0ce1d496ba04fc5a313ac20c8a665a17a9d3c50 100644 (file)
--- a/xsv.c
+++ b/xsv.c
@@ -871,6 +871,7 @@ static const char short_options[] = "cd:f:hqr:twW";
 
 enum long_options {
        OPT_HELP = 256,
+       OPT_VERSION,
        OPT_TRIM,
        OPT_ALWAYS_QUOTE,
        OPT_TABLE,
@@ -887,6 +888,7 @@ static const struct option long_options[] = {
        { "fs",                 1,      NULL,   'd' },
        { "grid",               0,      NULL,   OPT_GRID },
        { "header",             0,      NULL,   'h' },
+       { "help",               0,      NULL,   OPT_HELP },
        { "quiet",              0,      NULL,   'q' },
        { "regex",              1,      NULL,   'r' },
        { "sloppy",             0,      NULL,   's' },
@@ -894,8 +896,8 @@ static const struct option long_options[] = {
        { "table-sep",          1,      NULL,   OPT_TABLE_SEP },
        { "trim",               0,      NULL,   OPT_TRIM },
        { "tsv",                0,      NULL,   't' },
+       { "version",            0,      NULL,   OPT_VERSION },
        { "ws",                 0,      NULL,   'w' },
-       { "help",               0,      NULL,   OPT_HELP },
        { NULL,                 0,      NULL,   0 },
 };
 
@@ -1001,6 +1003,9 @@ int main(int argc, char **argv)
                                break;
                        case OPT_HELP:
                                usage();
+                       case OPT_VERSION:
+                               puts("This is xsv version " VERSION ".");
+                               exit(0);
                        case OPT_TRIM:
                                want_trim = 1;
                                break;