mirror of
https://github.com/troglobit/finit.git
synced 2026-10-02 14:02:52 +07:00
initctl: Default to show services listing, not usage text
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -346,7 +346,7 @@ not return until the given command has fully completed.
|
||||
|
||||
```shell
|
||||
~ $ initctl -h
|
||||
Usage: initctl [OPTIONS] <COMMAND>
|
||||
Usage: initctl [OPTIONS] [COMMAND]
|
||||
|
||||
Options:
|
||||
-d, --debug Debug initctl (client)
|
||||
@@ -358,7 +358,7 @@ Commands:
|
||||
help This help text
|
||||
reload Reload *.conf in /etc/finit.d/ and activate changes
|
||||
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 clear <COND> Clear (deassert) condition => -COND
|
||||
cond show Show condition status
|
||||
|
||||
+15
-14
@@ -579,7 +579,7 @@ static int show_status(char *arg)
|
||||
static int usage(int rc)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: %s [OPTIONS] <COMMAND>\n"
|
||||
"Usage: %s [OPTIONS] [COMMAND]\n"
|
||||
"\n"
|
||||
"Options:\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"
|
||||
" 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"
|
||||
" status | show Show status of services\n"
|
||||
" status | show Show status of services, default command\n"
|
||||
"\n"
|
||||
" runlevel [0-9] Show or set runlevel: 0 halt, 6 reboot\n"
|
||||
" reboot Reboot system\n"
|
||||
@@ -625,6 +625,7 @@ static int do_help(char *arg)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int c;
|
||||
char *cmd, arg[120] = "";
|
||||
command_t command[] = {
|
||||
{ "debug", toggle_debug },
|
||||
{ "help", do_help },
|
||||
@@ -673,20 +674,20 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
screen_init();
|
||||
if (optind < argc) {
|
||||
char *cmd = argv[optind++];
|
||||
char arg[120] = "";
|
||||
|
||||
while (optind < argc) {
|
||||
strlcat(arg, argv[optind++], sizeof(arg));
|
||||
if (optind < argc)
|
||||
strlcat(arg, " ", sizeof(arg));
|
||||
}
|
||||
if (optind >= argc)
|
||||
return show_status(NULL);
|
||||
|
||||
for (c = 0; command[c].cmd; c++) {
|
||||
if (!strcmp(command[c].cmd, cmd))
|
||||
return command[c].cb(arg);
|
||||
}
|
||||
cmd = argv[optind++];
|
||||
while (optind < argc) {
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user