From 62ea9eb82d4aa9edf3cbe27a3cced88bf989bbcf Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 10 Jun 2019 19:50:10 +0200 Subject: code-review: Add a version number and `--version` program flag --- code-review | 9 ++++++++- doc/code-review.1 | 5 +++++ doc/code-review.1.txt | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/code-review b/code-review index a97df7a..d6ddab7 100755 --- a/code-review +++ b/code-review @@ -19,10 +19,12 @@ EX_USAGE=64 +VERSION=0.0.1 + function print_usage () { cat <<-EOF - usage: code-review [--help] [] + usage: code-review [--help] [--version] [] Commands: @@ -50,6 +52,11 @@ if [ -z "$subcommand" ] || [ "$1" = '--help' ] || [ "$1" = '-h' ]; then exit "$EX_USAGE" fi +if [ "$1" = '--version' ]; then + echo "$VERSION" + exit 0 +fi + if ! program_exists "${program}-${subcommand}"; then echo >&2 "${program}: '${subcommand}' is not a ${program} command. See '${program} --help'" exit "$EX_USAGE" diff --git a/doc/code-review.1 b/doc/code-review.1 index e671bff..06b013b 100644 --- a/doc/code-review.1 +++ b/doc/code-review.1 @@ -41,6 +41,11 @@ A collection of tools that facilitate code review on the command line\&. .RS 4 Print usage help\&. .RE +.PP +\-\-version +.RS 4 +Print the program version\&. +.RE .SH "COMMANDS" .PP changed\-files diff --git a/doc/code-review.1.txt b/doc/code-review.1.txt index 276399f..df2a087 100644 --- a/doc/code-review.1.txt +++ b/doc/code-review.1.txt @@ -18,6 +18,9 @@ OPTIONS -h, --help:: Print usage help. +--version:: + Print the program version. + COMMANDS -------- changed-files:: -- cgit v1.2.3