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
2022-01-30 11:02:38 +01:00
parent 176125deca
commit d12370568f
2 changed files with 14 additions and 5 deletions
+7 -3
View File
@@ -11,7 +11,7 @@
.Nd Control tool for Finit
.Sh SYNOPSIS
.Nm /sbin/initctl
.Op Fl bcfhlpqtv
.Op Fl bcfhlpqtvV
.Op COMMAND
.Sh DESCRIPTION
.Nm
@@ -41,16 +41,20 @@ Silent, only return status of command.
Skip table headings.
.It Fl v, -verbose
Verbose output, where applicable.
.It Fl V, -version
Show program version.
.El
.Sh COMMANDS
.Bl -tag -width Ds
.It Nm Ar debug
Toggle finit (daemon) debug to
Toggle
.Nm finit
(daemon) debug to
.Pa /dev/console
.It Nm Ar help
Show built-in help text
.It Nm Ar version
Show Finit (daemon) version
Show program version
.It Nm Ar ls | list
List all
.Cm *.conf
+7 -2
View File
@@ -891,12 +891,13 @@ static int usage(int rc)
" -q, --quiet Silent, only return status of command\n"
" -t, --no-heading Skip table headings\n"
" -v, --verbose Verbose output\n"
" -R, --version Show program version\n"
" -h, --help This help text\n"
"\n"
"Commands:\n"
" debug Toggle Finit (daemon) debug\n"
" help This help text\n"
" version Show Finit version\n"
" version Show program version\n"
"\n", prognm);
if (has_rcsd)
@@ -1031,6 +1032,7 @@ int main(int argc, char *argv[])
{ "quiet", 0, NULL, 'q' },
{ "no-heading", 0, NULL, 't' },
{ "verbose", 0, NULL, 'v' },
{ "version", 0, NULL, 'V' },
{ NULL, 0, NULL, 0 }
};
struct cmd cond[] = {
@@ -1090,7 +1092,7 @@ int main(int argc, char *argv[])
cgrp = cgroup_avail();
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) {
case '1':
ionce = 1;
@@ -1131,6 +1133,9 @@ int main(int argc, char *argv[])
case 'v':
verbose = 1;
break;
case 'V':
return show_version(NULL);
}
}