mirror of
https://github.com/troglobit/finit.git
synced 2026-11-29 21:08:21 +00:00
initctl: Default to show services listing, not usage text
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
e4401f92ad
commit
c092d22d48
2 files changed
+17
-16
No files matched your search
@@ -346,7 +346,7 @@ not return until the given command has fully completed.
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
~ $ initctl -h
|
~ $ initctl -h
|
||||||
Usage: initctl [OPTIONS] <COMMAND>
|
Usage: initctl [OPTIONS] [COMMAND]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-d, --debug Debug initctl (client)
|
-d, --debug Debug initctl (client)
|
||||||
@@ -358,7 +358,7 @@ Commands:
|
|||||||
help This help text
|
help This help text
|
||||||
reload Reload *.conf in /etc/finit.d/ and activate changes
|
reload Reload *.conf in /etc/finit.d/ and activate changes
|
||||||
runlevel [0-9] Show or set runlevel: 0 halt, 6 reboot
|
runlevel [0-9] Show or set runlevel: 0 halt, 6 reboot
|
||||||
status | show Show status of services
|
status | show Show status of services, default command
|
||||||
cond set <COND> Set (assert) condition => +COND
|
cond set <COND> Set (assert) condition => +COND
|
||||||
cond clear <COND> Clear (deassert) condition => -COND
|
cond clear <COND> Clear (deassert) condition => -COND
|
||||||
cond show Show condition status
|
cond show Show condition status
|
||||||
|
|||||||
+15
-14
@@ -579,7 +579,7 @@ static int show_status(char *arg)
|
|||||||
static int usage(int rc)
|
static int usage(int rc)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Usage: %s [OPTIONS] <COMMAND>\n"
|
"Usage: %s [OPTIONS] [COMMAND]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" -v, --verbose Verbose output\n"
|
" -v, --verbose Verbose output\n"
|
||||||
@@ -604,7 +604,7 @@ static int usage(int rc)
|
|||||||
" start <JOB|NAME>[:ID] Start service by job# or name, with optional ID\n"
|
" start <JOB|NAME>[:ID] Start service by job# or name, with optional ID\n"
|
||||||
" stop <JOB|NAME>[:ID] Stop/Pause a running service by job# or name\n"
|
" stop <JOB|NAME>[:ID] Stop/Pause a running service by job# or name\n"
|
||||||
" restart <JOB|NAME>[:ID] Restart (stop/start) service by job# or name\n"
|
" restart <JOB|NAME>[:ID] Restart (stop/start) service by job# or name\n"
|
||||||
" status | show Show status of services\n"
|
" status | show Show status of services, default command\n"
|
||||||
"\n"
|
"\n"
|
||||||
" runlevel [0-9] Show or set runlevel: 0 halt, 6 reboot\n"
|
" runlevel [0-9] Show or set runlevel: 0 halt, 6 reboot\n"
|
||||||
" reboot Reboot system\n"
|
" reboot Reboot system\n"
|
||||||
@@ -625,6 +625,7 @@ static int do_help(char *arg)
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
char *cmd, arg[120] = "";
|
||||||
command_t command[] = {
|
command_t command[] = {
|
||||||
{ "debug", toggle_debug },
|
{ "debug", toggle_debug },
|
||||||
{ "help", do_help },
|
{ "help", do_help },
|
||||||
@@ -673,20 +674,20 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
screen_init();
|
screen_init();
|
||||||
if (optind < argc) {
|
|
||||||
char *cmd = argv[optind++];
|
|
||||||
char arg[120] = "";
|
|
||||||
|
|
||||||
while (optind < argc) {
|
if (optind >= argc)
|
||||||
strlcat(arg, argv[optind++], sizeof(arg));
|
return show_status(NULL);
|
||||||
if (optind < argc)
|
|
||||||
strlcat(arg, " ", sizeof(arg));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (c = 0; command[c].cmd; c++) {
|
cmd = argv[optind++];
|
||||||
if (!strcmp(command[c].cmd, cmd))
|
while (optind < argc) {
|
||||||
return command[c].cb(arg);
|
strlcat(arg, argv[optind++], sizeof(arg));
|
||||||
}
|
if (optind < argc)
|
||||||
|
strlcat(arg, " ", sizeof(arg));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (c = 0; command[c].cmd; c++) {
|
||||||
|
if (!strcmp(command[c].cmd, cmd))
|
||||||
|
return command[c].cb(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return usage(1);
|
return usage(1);
|
||||||
|
|||||||
Reference in new issue
Block a user