initctl: add -v,--version command line option

This patch adds the -v,--version option to initctl, which acts as an
alias to the 'version' command.  For now they end up in the same old
function, printing the program version.  However, in time this will be
changed so that the 'version' command asks a running Finit for its
version instead of assuming the daemon is of the same version.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2022-01-30 11:02:38 +01:00
1 parent 176125deca
commit d12370568f
2 files changed
+14 -5

No files matched your search

+7 -3
View File
@@ -11,7 +11,7 @@
.Nd Control tool for Finit .Nd Control tool for Finit
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm /sbin/initctl .Nm /sbin/initctl
.Op Fl bcfhlpqtv .Op Fl bcfhlpqtvV
.Op COMMAND .Op COMMAND
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm .Nm
@@ -41,16 +41,20 @@ Silent, only return status of command.
Skip table headings. Skip table headings.
.It Fl v, -verbose .It Fl v, -verbose
Verbose output, where applicable. Verbose output, where applicable.
.It Fl V, -version
Show program version.
.El .El
.Sh COMMANDS .Sh COMMANDS
.Bl -tag -width Ds .Bl -tag -width Ds
.It Nm Ar debug .It Nm Ar debug
Toggle finit (daemon) debug to Toggle
.Nm finit
(daemon) debug to
.Pa /dev/console .Pa /dev/console
.It Nm Ar help .It Nm Ar help
Show built-in help text Show built-in help text
.It Nm Ar version .It Nm Ar version
Show Finit (daemon) version Show program version
.It Nm Ar ls | list .It Nm Ar ls | list
List all List all
.Cm *.conf .Cm *.conf
+7 -2
View File
@@ -891,12 +891,13 @@ static int usage(int rc)
" -q, --quiet Silent, only return status of command\n" " -q, --quiet Silent, only return status of command\n"
" -t, --no-heading Skip table headings\n" " -t, --no-heading Skip table headings\n"
" -v, --verbose Verbose output\n" " -v, --verbose Verbose output\n"
" -R, --version Show program version\n"
" -h, --help This help text\n" " -h, --help This help text\n"
"\n" "\n"
"Commands:\n" "Commands:\n"
" debug Toggle Finit (daemon) debug\n" " debug Toggle Finit (daemon) debug\n"
" help This help text\n" " help This help text\n"
" version Show Finit version\n" " version Show program version\n"
"\n", prognm); "\n", prognm);
if (has_rcsd) if (has_rcsd)
@@ -1031,6 +1032,7 @@ int main(int argc, char *argv[])
{ "quiet", 0, NULL, 'q' }, { "quiet", 0, NULL, 'q' },
{ "no-heading", 0, NULL, 't' }, { "no-heading", 0, NULL, 't' },
{ "verbose", 0, NULL, 'v' }, { "verbose", 0, NULL, 'v' },
{ "version", 0, NULL, 'V' },
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
struct cmd cond[] = { struct cmd cond[] = {
@@ -1090,7 +1092,7 @@ int main(int argc, char *argv[])
cgrp = cgroup_avail(); cgrp = cgroup_avail();
utmp = has_utmp(); utmp = has_utmp();
while ((c = getopt_long(argc, argv, "1bcdfh?pqtv", long_options, NULL)) != EOF) { while ((c = getopt_long(argc, argv, "1bcdfh?pqtvV", long_options, NULL)) != EOF) {
switch(c) { switch(c) {
case '1': case '1':
ionce = 1; ionce = 1;
@@ -1131,6 +1133,9 @@ int main(int argc, char *argv[])
case 'v': case 'v':
verbose = 1; verbose = 1;
break; break;
case 'V':
return show_version(NULL);
} }
} }