Commit 0fb1b22c authored by Hermann Mayer's avatar Hermann Mayer

[Binary][Docs] Added -v|--version argument to the binaries. Documented the new…

[Binary][Docs] Added -v|--version argument to the binaries. Documented the new arguments on the man pages. (See #14)
parent 39472c69
......@@ -9,7 +9,10 @@ export MAN := man
export INSTALL := install
XML_CONF := xml2-config
export CFLAGS = $(shell $(XML_CONF) --cflags) -Wall -Werror -g -O0
export VERSION := $(shell cat VERSION)
export MACHTYPE := $(shell $(CC) -dumpmachine)
export CFLAGS = $(shell $(XML_CONF) --cflags) -Wall -Werror -g -O0 \
-DVERSION="\"$(VERSION)\"" -DMACHTYPE="\"$(MACHTYPE)\""
export INCLUDES = $(shell $(XML_CONF) --libs) -lcurl -lcrypto -lconfig -lbcm2835
DESTDIR ?=
......
......@@ -30,6 +30,11 @@ The following options are understood:
.IP "" 4
Show the available arguments
.IP "" 0
.B -v --version
.IP "" 4
Show version information
.IP "" 0
.BI "-c --config " "<file>"
.IP "" 4
......
......@@ -29,6 +29,11 @@ The following options are understood:
.IP "" 4
Show the available operations / arguments
.IP "" 0
.B -v --version
.IP "" 4
Show version information
.IP "" 0
.BI "-c --config " "<file>"
.IP "" 4
......
......@@ -247,6 +247,19 @@ void daemonize()
}
}
void print_version(int exit_code)
{
utlog(LOG_NOTICE, "avm-motion-trigger, avm-motion-triggerd version %s (%s)\n",
VERSION, MACHTYPE);
utlog(LOG_NOTICE, "Copyright (C) 2015 Hermann Mayer\n");
utlog(LOG_NOTICE, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n");
utlog(LOG_NOTICE, "\n");
utlog(LOG_NOTICE, "This is free software; you are free to change and redistribute it.\n");
utlog(LOG_NOTICE, "There is NO WARRANTY, to the extent permitted by law.\n");
free_config(&conf);
exit(exit_code);
}
void print_help(int exit_code)
{
utlog(LOG_INFO, "avm-motion-triggerd [OPTION]\n");
......@@ -274,6 +287,7 @@ int main(int argc, char **argv)
static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{"config", required_argument, 0, 'c'},
{"foreground", no_argument, 0, 'f'},
{0, 0, 0, 0}
......@@ -282,7 +296,7 @@ int main(int argc, char **argv)
// getopt_long stores the option index here.
int option_index = 0;
c = getopt_long(argc, argv, "hfc:",
c = getopt_long(argc, argv, "hvfc:",
long_options, &option_index);
// Detect the end of the options.
......@@ -295,6 +309,10 @@ int main(int argc, char **argv)
print_help(EXIT_SUCCESS);
break;
case 'v':
print_version(EXIT_SUCCESS);
break;
case 'c':
config_file = optarg;
break;
......
......@@ -207,6 +207,19 @@ int on(struct config *c, char **args, size_t argc)
return EXIT_SUCCESS;
}
void print_version(int exit_code)
{
utlog(LOG_NOTICE, "avm-motion-trigger, avmctl version %s (%s)\n",
VERSION, MACHTYPE);
utlog(LOG_NOTICE, "Copyright (C) 2015 Hermann Mayer\n");
utlog(LOG_NOTICE, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n");
utlog(LOG_NOTICE, "\n");
utlog(LOG_NOTICE, "This is free software; you are free to change and redistribute it.\n");
utlog(LOG_NOTICE, "There is NO WARRANTY, to the extent permitted by law.\n");
free_config(&conf);
exit(exit_code);
}
void print_help(int exit_code)
{
utlog(LOG_INFO, "avmctl [OPTION] {COMMAND} ...\n");
......@@ -214,6 +227,7 @@ void print_help(int exit_code)
utlog(LOG_INFO, "Control AVM Smart Home switches.\n");
utlog(LOG_INFO, "\n");
utlog(LOG_INFO, " -h --help Show the available operations / arguments\n");
utlog(LOG_INFO, " -v --version Show version information\n");
utlog(LOG_INFO, " -c --config Set the path to a config file\n");
utlog(LOG_INFO, " -H --host Set a host for the operations (overwrites config host)\n");
utlog(LOG_INFO, " -u --user Set a username for session (overwrites config username)\n");
......@@ -254,6 +268,7 @@ int main(int argc, char **argv)
static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{"config", required_argument, 0, 'c'},
{"host", required_argument, 0, 'H'},
{"user", required_argument, 0, 'u'},
......@@ -264,7 +279,7 @@ int main(int argc, char **argv)
/* getopt_long stores the option index here. */
int option_index = 0;
c = getopt_long(argc, argv, "hc:H:u:p:",
c = getopt_long(argc, argv, "hvc:H:u:p:",
long_options, &option_index);
/* Detect the end of the options. */
......@@ -277,6 +292,10 @@ int main(int argc, char **argv)
print_help(EXIT_SUCCESS);
break;
case 'v':
print_version(EXIT_SUCCESS);
break;
case 'c':
config_file = optarg;
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment