diff options
-rw-r--r-- | man/systemctl.xml | 5 | ||||
-rw-r--r-- | src/shared/unit-name.c | 4 | ||||
-rw-r--r-- | src/shared/unit-name.h | 4 | ||||
-rw-r--r-- | src/systemctl/systemctl.c | 22 |
4 files changed, 32 insertions, 3 deletions
diff --git a/man/systemctl.xml b/man/systemctl.xml index 31f3b1a909..62446d7a57 100644 --- a/man/systemctl.xml +++ b/man/systemctl.xml @@ -106,6 +106,11 @@ certain unit types. If not specified units of in all load states will be shown.</para> + + <para>As a special case, if the argument + is <option>help</option>, a list of + allowed values will be printed and the + program will exit.</para> </listitem> </varlistentry> diff --git a/src/shared/unit-name.c b/src/shared/unit-name.c index 50031e608e..88ca0b8f2c 100644 --- a/src/shared/unit-name.c +++ b/src/shared/unit-name.c @@ -33,7 +33,7 @@ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \ ":-_.\\" -static const char* const unit_type_table[_UNIT_TYPE_MAX] = { +const char* const unit_type_table[_UNIT_TYPE_MAX] = { [UNIT_SERVICE] = "service", [UNIT_SOCKET] = "socket", [UNIT_TARGET] = "target", @@ -48,7 +48,7 @@ static const char* const unit_type_table[_UNIT_TYPE_MAX] = { DEFINE_STRING_TABLE_LOOKUP(unit_type, UnitType); -static const char* const unit_load_state_table[_UNIT_LOAD_STATE_MAX] = { +const char* const unit_load_state_table[_UNIT_LOAD_STATE_MAX] = { [UNIT_STUB] = "stub", [UNIT_LOADED] = "loaded", [UNIT_ERROR] = "error", diff --git a/src/shared/unit-name.h b/src/shared/unit-name.h index 7be346590e..d7528a3ac7 100644 --- a/src/shared/unit-name.h +++ b/src/shared/unit-name.h @@ -44,7 +44,7 @@ enum UnitType { }; enum UnitLoadState { - UNIT_STUB, + UNIT_STUB = 0, UNIT_LOADED, UNIT_ERROR, UNIT_MERGED, @@ -53,9 +53,11 @@ enum UnitLoadState { _UNIT_LOAD_STATE_INVALID = -1 }; +extern const char* const unit_type_table[]; const char *unit_type_to_string(UnitType i); UnitType unit_type_from_string(const char *s); +extern const char* const unit_load_state_table[]; const char *unit_load_state_to_string(UnitLoadState i); UnitLoadState unit_load_state_from_string(const char *s); diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 39f4e6c509..f6eed1cc7f 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -4058,6 +4058,22 @@ static int runlevel_help(void) { return 0; } +static int help_types(void) { + int i; + + puts("Available unit types:"); + for(i = UNIT_SERVICE; i < _UNIT_TYPE_MAX; i++) + if (unit_type_table[i]) + puts(unit_type_table[i]); + + puts("\nAvailable unit load states: "); + for(i = UNIT_STUB; i < _UNIT_LOAD_STATE_MAX; i++) + if (unit_type_table[i]) + puts(unit_load_state_table[i]); + + return 0; +} + static int systemctl_parse_argv(int argc, char *argv[]) { enum { @@ -4137,6 +4153,11 @@ static int systemctl_parse_argv(int argc, char *argv[]) { return 0; case 't': + if (streq(optarg, "help")) { + help_types(); + return 0; + } + if (unit_type_from_string(optarg) >= 0) { arg_type = optarg; break; @@ -4147,6 +4168,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) { } log_error("Unkown unit type or load state '%s'.", optarg); + log_info("Use -t help to see a list of allowed values."); return -EINVAL; case 'p': { char **l; |