]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udevadm: support special value 'help' for --action option
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 28 Jun 2019 19:03:06 +0000 (04:03 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 28 Jun 2019 19:10:14 +0000 (04:10 +0900)
man/udevadm.xml
src/udev/udevadm-test.c
src/udev/udevadm-trigger.c

index 396d418f831f6be347b7e6884e4d7deaba608e3f..d12c39b7651a4c3a7cd781bd2406496f0140be10 100644 (file)
             <para>Type of event to be triggered. Possible actions are <literal>add</literal>,
             <literal>remove</literal>, <literal>change</literal>, <literal>move</literal>,
             <literal>online</literal>, <literal>offline</literal>, <literal>bind</literal>,
-            and <literal>unbind</literal>. The default value is <literal>change</literal>.</para>
+            and <literal>unbind</literal>. Also, the special value <literal>help</literal> can be used
+            to list the possible actions. The default value is <literal>change</literal>.
+            </para>
           </listitem>
         </varlistentry>
         <varlistentry>
       <variablelist>
         <varlistentry>
           <term><option>-a</option></term>
-          <term><option>--action=<replaceable>string</replaceable></option></term>
+          <term><option>--action=<replaceable>ACTION</replaceable></option></term>
           <listitem>
-            <para>The action string.</para>
+            <para>The action string. The special value <literal>help</literal> may be used to list
+            known values.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
index 8124951422add08fa7e213f5e311bd9461afe489..7ad9993f09e979fe84e5db396f5965f22de6d774 100644 (file)
@@ -33,7 +33,7 @@ static int help(void) {
                "Test an event run.\n\n"
                "  -h --help                            Show this help\n"
                "  -V --version                         Show package version\n"
-               "  -a --action=ACTION                   Set action string\n"
+               "  -a --action=ACTION|help              Set action string\n"
                "  -N --resolve-names=early|late|never  When to resolve names\n"
                , program_invocation_short_name);
 
@@ -56,6 +56,11 @@ static int parse_argv(int argc, char *argv[]) {
                 case 'a': {
                         DeviceAction a;
 
+                        if (streq(optarg, "help")) {
+                                dump_device_action_table();
+                                return 0;
+                        }
+
                         a = device_action_from_string(optarg);
                         if (a < 0)
                                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
index f14010a2d0de3b368729856bb8917e9b552a72b5..77d95e513fb3ae4ddef8ecefcd2494b237bb6e9f 100644 (file)
@@ -115,7 +115,7 @@ static int help(void) {
                "  -t --type=                        Type of events to trigger\n"
                "          devices                     sysfs devices (default)\n"
                "          subsystems                  sysfs subsystems and drivers\n"
-               "  -c --action=ACTION                Event action value, default is \"change\"\n"
+               "  -c --action=ACTION|help           Event action value, default is \"change\"\n"
                "  -s --subsystem-match=SUBSYSTEM    Trigger devices from a matching subsystem\n"
                "  -S --subsystem-nomatch=SUBSYSTEM  Exclude devices from a matching subsystem\n"
                "  -a --attr-match=FILE[=VALUE]      Trigger devices with a matching attribute\n"
@@ -205,6 +205,10 @@ int trigger_main(int argc, char *argv[], void *userdata) {
                                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown type --type=%s", optarg);
                         break;
                 case 'c':
+                        if (streq(optarg, "help")) {
+                                dump_device_action_table();
+                                return 0;
+                        }
                         if (device_action_from_string(optarg) < 0)
                                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown action '%s'", optarg);