systemctl: implement --version

https://bugs.freedesktop.org/show_bug.cgi?id=29912
This commit is contained in:
Lennart Poettering 2010-09-06 02:42:49 +02:00
parent 2a8cd298f4
commit 35df8f27fa

View File

@ -3845,6 +3845,7 @@ static int systemctl_help(void) {
printf("%s [OPTIONS...] {COMMAND} ...\n\n" printf("%s [OPTIONS...] {COMMAND} ...\n\n"
"Send control commands to or query the systemd manager.\n\n" "Send control commands to or query the systemd manager.\n\n"
" -h --help Show this help\n" " -h --help Show this help\n"
" --version Show package version\n"
" -t --type=TYPE List only units of a particular type\n" " -t --type=TYPE List only units of a particular type\n"
" -p --property=NAME Show only properties by this name\n" " -p --property=NAME Show only properties by this name\n"
" -a --all Show all units/properties, including dead/empty ones\n" " -a --all Show all units/properties, including dead/empty ones\n"
@ -3979,6 +3980,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
enum { enum {
ARG_FAIL = 0x100, ARG_FAIL = 0x100,
ARG_VERSION,
ARG_SESSION, ARG_SESSION,
ARG_SYSTEM, ARG_SYSTEM,
ARG_GLOBAL, ARG_GLOBAL,
@ -3994,6 +3996,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
static const struct option options[] = { static const struct option options[] = {
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, ARG_VERSION },
{ "type", required_argument, NULL, 't' }, { "type", required_argument, NULL, 't' },
{ "property", required_argument, NULL, 'p' }, { "property", required_argument, NULL, 'p' },
{ "all", no_argument, NULL, 'a' }, { "all", no_argument, NULL, 'a' },
@ -4026,6 +4029,10 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
systemctl_help(); systemctl_help();
return 0; return 0;
case ARG_VERSION:
puts(PACKAGE_STRING);
return 0;
case 't': case 't':
arg_type = optarg; arg_type = optarg;
break; break;