From 2e2573fbe07d8a1750ccdda7e0a146fef55fd50d Mon Sep 17 00:00:00 2001 From: Mike Burns Date: Thu, 13 Jun 2013 13:22:05 +0200 Subject: Add version flag, -V Add a flag to print the package version: `-V`. This change also brings with it the libexec directory, so we can pull common code out. --- Makefile | 2 ++ bin/mkrc | 11 +++++++++-- bin/rcup | 10 ++++++++-- libexec/rcm/rcm.sh | 11 +++++++++++ 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 libexec/rcm/rcm.sh diff --git a/Makefile b/Makefile index 4723f07..f4c2b5c 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,12 @@ install: install -dm 0755 $(PREFIX)/bin install -dm 0755 $(PREFIX)/share/man/man1 install -dm 0755 $(PREFIX)/share/man/man5 + install -dm 0755 $(PREFIX)/libexec/rcm install -m 0755 bin/mkrc $(PREFIX)/bin install -m 0755 bin/rcup $(PREFIX)/bin install -m 0644 man/man1/rcup.1 $(PREFIX)/share/man/man1 install -m 0644 man/man1/mkrc.1 $(PREFIX)/share/man/man1 install -m 0644 man/man5/rcrc.5 $(PREFIX)/share/man/man5 + install -m 0644 libexec/rcm/rcm.sh $(PREFIX)/libexec/rcm .PHONY: install diff --git a/bin/mkrc b/bin/mkrc index a9eef9c..cf360bf 100755 --- a/bin/mkrc +++ b/bin/mkrc @@ -23,6 +23,8 @@ install_dotfile() { cd $prior_wd } +. `dirname $0`/../libexec/rcm/rcm.sh + if [ $# -eq 0 ]; then echo "Usage: dotfiles-add [-t tag] filename ..." exit 1 @@ -30,16 +32,21 @@ fi tag= verbosity=0 -while getopts vqt: opt; do +version=0 +while getopts Vvqt: opt; do case "$opt" in t) tag=$OPTARG;; v) verbosity=$(($verbosity + 1));; q) verbosity=$(($verbosity - 1));; + V) version=1 esac done shift $(($OPTIND-1)) -if [ $verbosity -ge 2 ]; then +if [ $version -eq 1 ]; then + version mkrc + exit 0 +elif [ $verbosity -ge 2 ]; then MV="$MV -v" INSTALL="$INSTALL -vv" elif [ $verbosity -eq 1 ]; then diff --git a/bin/rcup b/bin/rcup index d733ea0..0569997 100755 --- a/bin/rcup +++ b/bin/rcup @@ -137,16 +137,21 @@ metafile() { handle_command_line() { arg_tags="" verbosity=0 - while getopts qvt: opt; do + version=0 + while getopts Vqvt: opt; do case "$opt" in t) arg_tags="$arg_tags $OPTARG";; v) verbosity=$(($verbosity + 1));; q) verbosity=$(($verbosity - 1));; + V) version=1 esac done shift $(($OPTIND-1)) - if [ $verbosity -ge 2 ]; then + if [ $version -eq 1 ]; then + version rcup + exit 0 + elif [ $verbosity -ge 2 ]; then DEBUG=echo VERBOSE=echo PRINT=echo @@ -175,6 +180,7 @@ if [ -e $HOME/.rcrc ]; then . $HOME/.rcrc fi +. `dirname $0`/../libexec/rcm/rcm.sh handle_command_line $* cd $DOTFILES_DIR diff --git a/libexec/rcm/rcm.sh b/libexec/rcm/rcm.sh new file mode 100644 index 0000000..99262d7 --- /dev/null +++ b/libexec/rcm/rcm.sh @@ -0,0 +1,11 @@ +VERSION="0.0.1" + +version() { + cat << EOV +$1 (rcm) $VERSION +Copyright (C) 2013 Mike Burns +License BSD: BSD 3-clause license + +Written by Mike Burns. +EOV +} -- cgit v1.2.3