summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2013-10-11 23:08:42 (EDT)
committer P. J. McDermott <pjm@nac.net>2013-10-11 23:13:19 (EDT)
commit7ae90a0bacbfbbd4c3bc9d716b7f52e2e90e07fe (patch)
treed9de1f4cb69e71c83cee25cfbfd9fff11e3f6798
parentbc8c9b9e2b8553355a785f486367dcd3fdda5e4c (diff)
version: New command.
-rw-r--r--NEWS1
-rw-r--r--lib/cmd/local.mk1
-rw-r--r--lib/cmd/version.sh30
-rw-r--r--locale/en_US/pro_archman.sh4
-rw-r--r--man/pro-archman.1in3
-rw-r--r--src/pro-archman.sh7
6 files changed, 45 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index f3b11f8..e827aa8 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Changes in this release:
* The process-incoming command now removes processed files.
* All output is now sent to stderr. (Previously, only some of it was.)
* An example archive "conf" file is now provided in the source tree.
+ * A new "version" command and "-V" option have been added.
ProteanOS Archive Manager version 1.0.0
---------------------------------------
diff --git a/lib/cmd/local.mk b/lib/cmd/local.mk
index a41a1a8..5687a3e 100644
--- a/lib/cmd/local.mk
+++ b/lib/cmd/local.mk
@@ -3,6 +3,7 @@
pkglibcmd_srcs = \
lib/cmd/help.sh \
+ lib/cmd/version.sh \
lib/cmd/include.sh \
lib/cmd/process-incoming.sh \
lib/cmd/remove.sh \
diff --git a/lib/cmd/version.sh b/lib/cmd/version.sh
new file mode 100644
index 0000000..e1d27b4
--- /dev/null
+++ b/lib/cmd/version.sh
@@ -0,0 +1,30 @@
+# pro-archman
+# lib/cmd/version.sh
+# "version" command
+#
+# Copyright (C) 2013 Patrick "P. J." McDermott
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+cmd_version_main()
+{
+ printf '%s %s\n' "${PACKAGE_NAME}" "${PACKAGE_VERSION}"
+
+ cat <<EOF
+Copyright (C) 2013 Patrick "P. J." McDermott
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.
+EOF
+}
diff --git a/locale/en_US/pro_archman.sh b/locale/en_US/pro_archman.sh
index 21404c6..ce569b1 100644
--- a/locale/en_US/pro_archman.sh
+++ b/locale/en_US/pro_archman.sh
@@ -30,6 +30,10 @@ msg_pro_archman_cmd_help_summary_head='Where <command> is one of:'
msg_pro_archman_cmd_help_summary='print this help message'
msg_pro_archman_cmd_help_usage='[<command>]'
+# lib/cmd/version.sh
+msg_pro_archman_cmd_version_summary='print version information'
+msg_pro_archman_cmd_version_usage=''
+
# lib/cmd/include.sh
msg_pro_archman_cmd_include_summary='include packages described in changes files'
msg_pro_archman_cmd_include_usage='<changes> ...'
diff --git a/man/pro-archman.1in b/man/pro-archman.1in
index 174bd9d..4ff5137 100644
--- a/man/pro-archman.1in
+++ b/man/pro-archman.1in
@@ -19,6 +19,9 @@ manages packages in an archive.
.B help
Print a help message.
.TP
+.B version
+Print version information.
+.TP
.B include \fIchanges\fP \fR...\fP
Include packages described in changes files.
.TP
diff --git a/src/pro-archman.sh b/src/pro-archman.sh
index 8996367..8df75f1 100644
--- a/src/pro-archman.sh
+++ b/src/pro-archman.sh
@@ -22,6 +22,8 @@
set -u
# Constant global variables
+PACKAGE_NAME='@@PACKAGE_NAME@@'
+PACKAGE_VERSION='@@PACKAGE_VERSION@@'
PKGLIBDIR='@@PKGLIBDIR@@'
PKGLIBCMDDIR='@@PKGLIBCMDDIR@@'
PKGLIBCMD='@@PKGLIBCMD@@'
@@ -123,7 +125,7 @@ get_options()
{
local opt=
- while getopts 'b:h' opt; do
+ while getopts 'b:hV' opt; do
case "${opt}" in
'b')
opt_base_dir="$(cd "${OPTARG}" && pwd)"
@@ -131,6 +133,9 @@ get_options()
'h')
opt_cmd='help'
;;
+ 'V')
+ opt_cmd='version'
+ ;;
esac
done