diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-09-28 13:29:03 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-09-28 15:09:34 -0400 |
commit | e16972e6265d5e9326ec21d7e90f715989f96548 (patch) | |
tree | 79fc657ed7cde9e80487ebd47c13f755dd4bad42 /src/systemctl | |
parent | 978c8b6347d61f5a792886ef1875a4df625fd65f (diff) |
systemctl: add --state=help
This mirrors --type=help and simplifies completion scripts.
The array of states is dense, so the is no need to check if the string is null.
Diffstat (limited to 'src/systemctl')
-rw-r--r-- | src/systemctl/systemctl.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 34e4751b94..600d985978 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -6314,15 +6314,25 @@ static void runlevel_help(void) { static void help_types(void) { int i; - const char *t; if (!arg_no_legend) puts("Available unit types:"); - for (i = 0; i < _UNIT_TYPE_MAX; i++) { - t = unit_type_to_string(i); - if (t) - puts(t); - } + for (i = 0; i < _UNIT_TYPE_MAX; i++) + puts(unit_type_to_string(i)); +} + +static void help_states(void) { + int i; + + if (!arg_no_legend) + puts("Available unit load states:"); + for (i = 0; i < _UNIT_LOAD_STATE_MAX; i++) + puts(unit_load_state_to_string(i)); + + if (!arg_no_legend) + puts("\nAvailable unit active states:"); + for (i = 0; i < _UNIT_ACTIVE_STATE_MAX; i++) + puts(unit_active_state_to_string(i)); } static int systemctl_parse_argv(int argc, char *argv[]) { @@ -6660,6 +6670,11 @@ static int systemctl_parse_argv(int argc, char *argv[]) { if (!s) return log_oom(); + if (streq(s, "help")) { + help_states(); + return 0; + } + if (strv_consume(&arg_states, s) < 0) return log_oom(); } |