systemctl: add help for --type/-t
The list of types and load states if lengthy, so a little reminder can be sometimes useful.
This commit is contained in:
parent
48c2826b4e
commit
45c0c61df3
|
@ -106,6 +106,11 @@
|
||||||
certain unit types. If not specified
|
certain unit types. If not specified
|
||||||
units of in all load states will be
|
units of in all load states will be
|
||||||
shown.</para>
|
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>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
|
||||||
":-_.\\"
|
":-_.\\"
|
||||||
|
|
||||||
static const char* const unit_type_table[_UNIT_TYPE_MAX] = {
|
const char* const unit_type_table[_UNIT_TYPE_MAX] = {
|
||||||
[UNIT_SERVICE] = "service",
|
[UNIT_SERVICE] = "service",
|
||||||
[UNIT_SOCKET] = "socket",
|
[UNIT_SOCKET] = "socket",
|
||||||
[UNIT_TARGET] = "target",
|
[UNIT_TARGET] = "target",
|
||||||
|
@ -48,7 +48,7 @@ static const char* const unit_type_table[_UNIT_TYPE_MAX] = {
|
||||||
|
|
||||||
DEFINE_STRING_TABLE_LOOKUP(unit_type, UnitType);
|
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_STUB] = "stub",
|
||||||
[UNIT_LOADED] = "loaded",
|
[UNIT_LOADED] = "loaded",
|
||||||
[UNIT_ERROR] = "error",
|
[UNIT_ERROR] = "error",
|
||||||
|
|
|
@ -44,7 +44,7 @@ enum UnitType {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum UnitLoadState {
|
enum UnitLoadState {
|
||||||
UNIT_STUB,
|
UNIT_STUB = 0,
|
||||||
UNIT_LOADED,
|
UNIT_LOADED,
|
||||||
UNIT_ERROR,
|
UNIT_ERROR,
|
||||||
UNIT_MERGED,
|
UNIT_MERGED,
|
||||||
|
@ -53,9 +53,11 @@ enum UnitLoadState {
|
||||||
_UNIT_LOAD_STATE_INVALID = -1
|
_UNIT_LOAD_STATE_INVALID = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern const char* const unit_type_table[];
|
||||||
const char *unit_type_to_string(UnitType i);
|
const char *unit_type_to_string(UnitType i);
|
||||||
UnitType unit_type_from_string(const char *s);
|
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);
|
const char *unit_load_state_to_string(UnitLoadState i);
|
||||||
UnitLoadState unit_load_state_from_string(const char *s);
|
UnitLoadState unit_load_state_from_string(const char *s);
|
||||||
|
|
||||||
|
|
|
@ -4058,6 +4058,22 @@ static int runlevel_help(void) {
|
||||||
return 0;
|
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[]) {
|
static int systemctl_parse_argv(int argc, char *argv[]) {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -4137,6 +4153,11 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
|
if (streq(optarg, "help")) {
|
||||||
|
help_types();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (unit_type_from_string(optarg) >= 0) {
|
if (unit_type_from_string(optarg) >= 0) {
|
||||||
arg_type = optarg;
|
arg_type = optarg;
|
||||||
break;
|
break;
|
||||||
|
@ -4147,6 +4168,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
log_error("Unkown unit type or load state '%s'.",
|
log_error("Unkown unit type or load state '%s'.",
|
||||||
optarg);
|
optarg);
|
||||||
|
log_info("Use -t help to see a list of allowed values.");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
case 'p': {
|
case 'p': {
|
||||||
char **l;
|
char **l;
|
||||||
|
|
Loading…
Reference in New Issue