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]`|`--maxscalelog=[yes no]`|log messages to MaxScale log (default: yes)
`-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
<a name="stopping"></a>

View File

@ -56,6 +56,9 @@ Log messages to MaxScale's own log files.
.BR "-v, --version"
Print version information and exit.
.TP
.BR "-V, --version-full"
Print full version information including the Git commit the binary was built from and exit.
.TP
.BR "-?, --help"
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 const char* maxscale_commit = MAXSCALE_COMMIT;
const char *progname = NULL;
static struct option long_options[] = {
{"homedir", required_argument, 0, 'c'},
@ -178,6 +180,7 @@ static struct option long_options[] = {
{"user",required_argument,0,'U'},
{"version", no_argument, 0, 'v'},
{"help", no_argument, 0, '?'},
{"version-full", no_argument, 0, 'V'},
{0, 0, 0, 0}
};
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,
"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",
cnf->sysname, cnf->release_string, cnf->version_string);
maxscale_commit, cnf->sysname, cnf->release_string, cnf->version_string);
{
void *addrs[128];
@ -1015,6 +1018,7 @@ static void usage(void)
" -s, --syslog=[yes|no] log messages to syslog (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-full print full version info and exit\n"
" -?, --help show this help\n"
, 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)
{
bool succp = true;
@ -1154,7 +1158,12 @@ int main(int argc, char **argv)
case 'v':
rc = EXIT_SUCCESS;
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':
if (strncasecmp(optarg, "file", PATH_MAX) == 0)