Added --version-full which prints version and commit ID.

This commit is contained in:
Markus Makela
2015-09-02 08:57:00 +03:00
parent b66dfaa8ec
commit e55d345ab4
3 changed files with 17 additions and 4 deletions

View File

@ -44,6 +44,7 @@ Switch|Long Option|Description
`-s [yes no]`|`--syslog=[yes no]`|log messages to syslog (default:yes) `-s [yes no]`|`--syslog=[yes no]`|log messages to syslog (default:yes)
`-S [yes no]`|`--maxscalelog=[yes no]`|log messages to MaxScale log (default: yes) `-S [yes no]`|`--maxscalelog=[yes no]`|log messages to MaxScale log (default: yes)
`-v`|`--version`|print version info and exit `-v`|`--version`|print version info and exit
`-V`|`--version-full`|print version info and the commit ID the binary was built from
`-?`|`--help`|show this help `-?`|`--help`|show this help
<a name="stopping"></a> <a name="stopping"></a>

View File

@ -56,6 +56,9 @@ Log messages to MaxScale's own log files.
.BR "-v, --version" .BR "-v, --version"
Print version information and exit. Print version information and exit.
.TP .TP
.BR "-V, --version-full"
Print full version information including the Git commit the binary was built from and exit.
.TP
.BR "-?, --help" .BR "-?, --help"
Show the help information for MaxScale and exit. Show the help information for MaxScale and exit.

View File

@ -160,6 +160,8 @@ static bool libmysqld_started = FALSE;
*/ */
static bool daemon_mode = true; static bool daemon_mode = true;
static const char* maxscale_commit = MAXSCALE_COMMIT;
const char *progname = NULL; const char *progname = NULL;
static struct option long_options[] = { static struct option long_options[] = {
{"homedir", required_argument, 0, 'c'}, {"homedir", required_argument, 0, 'c'},
@ -178,6 +180,7 @@ static struct option long_options[] = {
{"user",required_argument,0,'U'}, {"user",required_argument,0,'U'},
{"version", no_argument, 0, 'v'}, {"version", no_argument, 0, 'v'},
{"help", no_argument, 0, '?'}, {"help", no_argument, 0, '?'},
{"version-full", no_argument, 0, 'V'},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
static int cnf_preparser(void* data, const char* section, const char* name, const char* value); static int cnf_preparser(void* data, const char* section, const char* name, const char* value);
@ -395,9 +398,9 @@ sigfatal_handler (int i)
LOGFILE_ERROR, LOGFILE_ERROR,
"Fatal: MaxScale "MAXSCALE_VERSION" received fatal signal %d. Attempting backtrace.", i))); "Fatal: MaxScale "MAXSCALE_VERSION" received fatal signal %d. Attempting backtrace.", i)));
skygw_log_write_flush(LE,"Commit ID: "MAXSCALE_COMMIT" System name: %s " skygw_log_write_flush(LE,"Commit ID: %s System name: %s "
"Release string: %s Embedded library version: %s", "Release string: %s Embedded library version: %s",
cnf->sysname, cnf->release_string, cnf->version_string); maxscale_commit, cnf->sysname, cnf->release_string, cnf->version_string);
{ {
void *addrs[128]; void *addrs[128];
@ -1015,6 +1018,7 @@ static void usage(void)
" -s, --syslog=[yes|no] log messages to syslog (default:yes)\n" " -s, --syslog=[yes|no] log messages to syslog (default:yes)\n"
" -S, --maxscalelog=[yes|no] log messages to MaxScale log (default: yes)\n" " -S, --maxscalelog=[yes|no] log messages to MaxScale log (default: yes)\n"
" -v, --version print version info and exit\n" " -v, --version print version info and exit\n"
" -V, --version-full print full version info and exit\n"
" -?, --help show this help\n" " -?, --help show this help\n"
, progname); , progname);
} }
@ -1118,7 +1122,7 @@ int main(int argc, char **argv)
} }
} }
while ((opt = getopt_long(argc, argv, "dc:f:l:vs:S:?L:D:C:B:U:A:P:", while ((opt = getopt_long(argc, argv, "dc:f:l:vVs:S:?L:D:C:B:U:A:P:",
long_options, &option_index)) != -1) long_options, &option_index)) != -1)
{ {
bool succp = true; bool succp = true;
@ -1156,6 +1160,11 @@ int main(int argc, char **argv)
printf("MaxScale %s\n", MAXSCALE_VERSION); printf("MaxScale %s\n", MAXSCALE_VERSION);
goto return_main; goto return_main;
case 'V':
rc = EXIT_SUCCESS;
printf("MaxScale %s - %s\n", MAXSCALE_VERSION, maxscale_commit);
goto return_main;
case 'l': case 'l':
if (strncasecmp(optarg, "file", PATH_MAX) == 0) if (strncasecmp(optarg, "file", PATH_MAX) == 0)
logtofile = 1; logtofile = 1;