From a618ac038d9a85bf6a7d84d7b87e58bd81fe6af8 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 24 Jul 2012 18:55:53 +0200 Subject: [PATCH] Added version number everywhere --- Makefile | 6 ++++-- xsv.1.txt | 2 +- xsv.c | 7 ++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index db742f4..80eeeeb 100644 --- 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 .#*` diff --git a/xsv.1.txt b/xsv.1.txt index 921febf..e392528 100644 --- 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 b11946c..c0ce1d4 100644 --- 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; -- 2.39.2