chiark / gitweb /
systemctl: make list-dependencies default to default.target
authorLennart Poettering <lennart@poettering.net>
Thu, 17 Jan 2013 23:36:12 +0000 (00:36 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 17 Jan 2013 23:36:12 +0000 (00:36 +0100)
man/systemctl.xml
src/systemctl/systemctl.c

index f223383..60a0f40 100644 (file)
                         <varlistentry>
                                 <term><command>list-dependencies [NAME]</command></term>
 
-                                <listitem><para>
-                                Shows required and wanted units of given unit.
-                                Target units are recursively expanded.
-                                When <option>--all</option> is passed
-                                dependency tree is generated for all
-                                subsidiary units.</para>
+                                <listitem><para> Shows required and
+                                wanted units of the specified unit. If
+                                no unit is specified
+                                <filename>default.target</filename> is
+                                implied. Target units are recursively
+                                expanded.  When <option>--all</option>
+                                is passed all other units aare
+                                recursively expanded as well.</para>
                                 </listitem>
                         </varlistentry>
                         <varlistentry>
index 003b706..3568543 100644 (file)
@@ -905,20 +905,24 @@ finish:
 }
 
 static int list_dependencies(DBusConnection *bus, char **args) {
-        int r = 0;
         _cleanup_free_ char *unit = NULL;
+        const char *u;
 
         assert(bus);
-        assert(args[1]);
 
-        unit = unit_name_mangle(args[1]);
-        if (!unit)
-                return log_oom();
+        if (args[1]) {
+                unit = unit_name_mangle(args[1]);
+                if (!unit)
+                        return log_oom();
+                u = unit;
+        } else
+                u = SPECIAL_DEFAULT_TARGET;
 
         pager_open_if_enabled();
-        printf("%s\n", unit);
-        r = list_dependencies_one(bus, unit, 0, NULL, 0);
-        return r;
+
+        puts(u);
+
+        return list_dependencies_one(bus, u, 0, NULL, 0);
 }
 
 static int dot_one_property(const char *name, const char *prop, DBusMessageIter *iter) {
@@ -5301,7 +5305,7 @@ static int systemctl_main(DBusConnection *bus, int argc, char *argv[], DBusError
                 { "unmask",                MORE,  2, enable_unit       },
                 { "link",                  MORE,  2, enable_unit       },
                 { "switch-root",           MORE,  2, switch_root       },
-                { "list-dependencies",     EQUAL, 2, list_dependencies },
+                { "list-dependencies",     LESS,  2, list_dependencies },
         };
 
         int left;