diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2018-07-18 13:10:30 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2018-07-18 13:12:56 +0300 |
commit | 46a93f1575cff6a1afa1d793a33f87d3c655ac83 (patch) | |
tree | 9f3e650ced658e2dd71cf3ec2a978c51de8c09d8 | |
parent | e7b4a06a27acce5ab555bac18d52485aa18df1d0 (diff) | |
download | tallyman-46a93f1575cff6a1afa1d793a33f87d3c655ac83.tar.gz tallyman-46a93f1575cff6a1afa1d793a33f87d3c655ac83.tar.bz2 |
Implement --version option
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/gpl3.h | 8 | ||||
-rw-r--r-- | src/stevedore.8 | 8 | ||||
-rw-r--r-- | src/stevedore.c | 15 | ||||
-rw-r--r-- | src/tallyman.1 | 10 | ||||
-rw-r--r-- | src/tallyman.c | 15 |
6 files changed, 52 insertions, 7 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 23e9245..ece3c6f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,7 +27,6 @@ stevedore_SOURCES = \ tallyman_mib.h\ subagent.c - AM_CPPFLAGS=@GRECS_INCLUDES@ @RUNCAP_INC@ -DSYSCONFDIR="\"$(sysconfdir)\"" stevedore_LDADD=\ @GRECS_LDADD@\ @@ -37,7 +36,7 @@ stevedore_LDADD=\ tallyman_LDADD=@GRECS_LDADD@ @RUNCAP_LDADD@ tallyman_LDFLAGS= -noinst_HEADERS = defs.h +noinst_HEADERS = defs.h gpl3.h if TMD_WRAP stevedore_SOURCES += wrapacl.c diff --git a/src/gpl3.h b/src/gpl3.h new file mode 100644 index 0000000..47947a0 --- /dev/null +++ b/src/gpl3.h @@ -0,0 +1,8 @@ +char license[] = "\ +Copyright (C) 2018 Sergey Poznyakoff\n\ +License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\ +This is free software: you are free to change and redistribute it.\n\ +There is NO WARRANTY, to the extent permitted by law.\n"; + + + diff --git a/src/stevedore.8 b/src/stevedore.8 index b6d5c21..5ef83b1 100644 --- a/src/stevedore.8 +++ b/src/stevedore.8 @@ -13,7 +13,10 @@ stevedore \- container state collector and SNMP agent daemon [\fB\-\-debug\fR] .sp \fBstevedore\fR\ - \fB\-?\fR | \fB\-\-help\fR | \fB\-\-config\-help\fR + \fB\-?\fR |\ + \fB\-\-help\fR |\ + \fB\-V\fR |\ + \fB\-\-version\fR .ad .hy .SH DESCRIPTION @@ -157,6 +160,9 @@ Increase debug verbosity. .TP \fB\-?\fR, \fB\-\-help\fR Display short usage summary. +.TP +\fB\-V\fR, \fB\-\-version\fR +Display program version and licensing information and exit. .SH MIB The MIB is kept in file \fBTALLYMAN-MIB.txt\fR which is normally installed to the location where \fBnet-snmp\fR tools expect to find diff --git a/src/stevedore.c b/src/stevedore.c index 1644786..fd1eb1c 100644 --- a/src/stevedore.c +++ b/src/stevedore.c @@ -40,9 +40,10 @@ struct option longopts[] = { { "debug", no_argument, 0, 'd' }, { "foreground", no_argument, 0, 'F' }, { "single", no_argument, 0, 's' }, + { "version", no_argument, 0, 'V' }, { NULL } }; -static char shortopts[] = "?df:Fs"; +static char shortopts[] = "?df:FsV"; void help(void) @@ -56,8 +57,17 @@ help(void) printf(" -F, --foreground don't fork; remain in foreground\n"); printf(" -s, --single don't start sentinel process\n"); printf(" -d, --debug increase debug verbosity\n"); + printf(" -V, --version display version number and license\n"); printf(" -?, --help display this help text\n\n"); } + +#include "gpl3.h" +void +version(void) +{ + printf("stevedore (%s) %s\n", PACKAGE_TARNAME, PACKAGE_VERSION); + printf("%s\n", license); +} static void logger_syslog(int prio, int ec, char const *pfx, char const *msg) @@ -596,6 +606,9 @@ main(int argc, char **argv) case 's': single_process = 1; break; + case 'V': + version(); + exit(0); case OPT_CONFIG_HELP: config_help(); exit(0); diff --git a/src/tallyman.1 b/src/tallyman.1 index 542ca24..90a1baa 100644 --- a/src/tallyman.1 +++ b/src/tallyman.1 @@ -20,7 +20,10 @@ tallyman \- health state collector for docker containers \fIARGS\fR... .sp \fBtallyman\fR\ - \fB\-?\fR | \fB\-\-help\fR + \fB\-?\fR |\ + \fB\-\-help\fR |\ + \fB\-V\fR |\ + \fB\-\-version\fR .ad .hy .SH DESCRIPTION @@ -60,7 +63,10 @@ Set timeout for initial connection to the collector. Default is 5 seconds. Set \fICOMMAND\fR execution timeout. Default is 5 seconds. .TP \fB\-?\fR, \fB\-\-help\fR -Display short help text. +Display short help text and exit. +.TP +\fB\-V\fR, \fB\-\-version\fR +Display program version and licensing information and exit. .SH "SEE ALSO" .BR stevedore (8). .SH AUTHORS diff --git a/src/tallyman.c b/src/tallyman.c index 7181381..f6b095d 100644 --- a/src/tallyman.c +++ b/src/tallyman.c @@ -37,9 +37,10 @@ struct option longopts[] = { { "debug", no_argument, 0, 'd' }, { "connection-timeout", required_argument, 0, OPT_CONNECTION_TIMEOUT }, { "execution-timeout", required_argument, 0, OPT_EXECUTION_TIMEOUT }, + { "version", no_argument, 0, 'V' }, { NULL } }; -static char shortopts[] = "+?ds:h:v:"; +static char shortopts[] = "+?ds:h:v:V"; void help(void) @@ -55,9 +56,18 @@ help(void) printf(" set connection timeout\n"); printf(" --execution-timeout=SECONDS\n"); printf(" set execution timeout\n"); + printf(" -V, --version display version number and license\n"); printf(" -?, --help display this help text\n\n"); } +#include "gpl3.h" +void +version(void) +{ + printf("tallyman (%s) %s\n", PACKAGE_TARNAME, PACKAGE_VERSION); + printf("%s\n", license); +} + static int get_timeout(char const *arg) { @@ -199,6 +209,9 @@ main(int argc, char **argv) case 'd': shttp_verbose++; break; + case 'V': + version(); + exit(0); case OPT_CONNECTION_TIMEOUT: exec_timeout = get_timeout(optarg); break; |