]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virt-pki-validate: add --help/--version option
authorEric Blake <eblake@redhat.com>
Mon, 19 Aug 2013 22:38:57 +0000 (16:38 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 20 Aug 2013 02:25:53 +0000 (20:25 -0600)
Another program gains --help/--version :)

* tools/virt-pki-validate.in: Add option parsing.  Update
documentation to match.
* tools/Makefile.am (virt-pki-validate): Substitute version.

Signed-off-by: Eric Blake <eblake@redhat.com>
tools/Makefile.am
tools/virt-pki-validate.in

index 03c9fd0007c9a2942dc925f0ffb965cba5afc1e6..ef6e31b54aa5be76fdd7fe0eeb159b032e3f0ecd 100644 (file)
@@ -87,8 +87,9 @@ virt-xml-validate.1: virt-xml-validate.in $(top_srcdir)/configure.ac
                rm $(srcdir)/$@; exit 1; fi
 
 virt-pki-validate: virt-pki-validate.in Makefile
-       $(AM_V_GEN)sed -e 's|[@]sysconfdir@|$(sysconfdir)|' < $< > $@ \
-           || (rm $@ && exit 1) && chmod +x $@
+       $(AM_V_GEN)sed -e 's|[@]sysconfdir@|$(sysconfdir)|g' \
+                      -e 's|[@]VERSION@|$(VERSION)|g' \
+         < $< > $@ || (rm $@ && exit 1) && chmod +x $@
 
 virt-pki-validate.1: virt-pki-validate.in $(top_srcdir)/configure.ac
        $(AM_V_GEN)$(POD2MAN) --name VIRT-PKI-VALIDATE $< $(srcdir)/$@ \
index 5d0453f0089bf5b3feb3ab05d306ae5d6d08e8c9..cda55d158ceb24a1242f4a9a8308fa4d2a9bd1ac 100755 (executable)
 #
 # Daniel Veillard <veillard@redhat.com>
 #
+
+case $1 in
+  -h | --h | --he | --hel | --help)
+    cat <<EOF
+Usage:
+  $0 [OPTION]
+
+Options:
+  -h | --help        Display program help
+  -V | --version     Display program version
+EOF
+    exit ;;
+  -V | --v | --ve | --ver | --vers | --versi | --versio | --version)
+    cat <<EOF
+$0 (libvirt) @VERSION@
+EOF
+    exit ;;
+  --) shift ;;
+  -) # Not an option but an argument; it gets rejected later
+    ;;
+  -*)
+    echo "$0: unrecognized option '$1'" >&2
+    exit 1 ;;
+esac
+
+if test $# != 0; then
+    echo "$0: unrecognized argument '$1'" >&2
+    exit 1
+fi
+
 USER=`who am i | awk '{ print $1 }'`
 SERVER=1
 CLIENT=1
@@ -300,7 +330,7 @@ exit 0
 
 =head1 SYNOPSIS
 
-  virt-pki-validate
+  virt-pki-validate [OPTION]
 
 =head1 DESCRIPTION
 
@@ -309,6 +339,20 @@ a secure libvirt server or client using the TLS encryption protocol.
 It will report any missing certificate or key files on the host. It
 should be run as root to ensure it can read all the necessary files
 
+=head1 OPTIONS
+
+=over
+
+=item B<-h, --help>
+
+Display command line help usage then exit.
+
+=item B<-V, --version>
+
+Display version information then exit.
+
+=back
+
 =head1 EXIT STATUS
 
 Upon successful validation, an exit status of 0 will be set. Upon