chiark / gitweb /
systemctl: use format_timespan() where applicable
[elogind.git] / src / systemctl.c
index 12ddae859e8a4c232d6c4b15b72e5170e8270758..226ecee3adfaeb82d603864c59850a534b3fd8ec 100644 (file)
@@ -1029,6 +1029,10 @@ static int print_property(const char *name, DBusMessageIter *iter) {
 
                         if ((t = format_timestamp(timestamp, sizeof(timestamp), u)) || arg_all)
                                 printf("%s=%s\n", name, strempty(t));
+                } else if (strstr(name, "USec")) {
+                        char timespan[FORMAT_TIMESPAN_MAX];
+
+                        printf("%s=%s\n", name, format_timespan(timespan, sizeof(timespan), u));
                 } else
                         printf("%s=%llu\n", name, (unsigned long long) u);
 
@@ -1165,11 +1169,14 @@ static int print_property(const char *name, DBusMessageIter *iter) {
 
                                 if (bus_iter_get_basic_and_next(&sub2, DBUS_TYPE_STRING, &base, true) >= 0 &&
                                     bus_iter_get_basic_and_next(&sub2, DBUS_TYPE_UINT64, &value, true) >= 0 &&
-                                    bus_iter_get_basic_and_next(&sub2, DBUS_TYPE_UINT64, &next_elapse, false) >= 0)
-                                        printf("%s={ value=%llu ; next_elapse=%llu }\n",
+                                    bus_iter_get_basic_and_next(&sub2, DBUS_TYPE_UINT64, &next_elapse, false) >= 0) {
+                                        char timespan1[FORMAT_TIMESPAN_MAX], timespan2[FORMAT_TIMESPAN_MAX];
+
+                                        printf("%s={ value=%s ; next_elapse=%s }\n",
                                                base,
-                                               (unsigned long long) value,
-                                               (unsigned long long) next_elapse);
+                                               format_timespan(timespan1, sizeof(timespan1), value),
+                                               format_timespan(timespan2, sizeof(timespan2), next_elapse));
+                                }
 
                                 dbus_message_iter_next(&sub);
                         }
@@ -2106,7 +2113,7 @@ static int systemctl_help(void) {
                "Send control commands to the systemd manager.\n\n"
                "  -h --help          Show this help\n"
                "  -t --type=TYPE     List only units of a particular type\n"
-               "  -p --property=NAME Show only property by this name\n"
+               "  -p --property=NAME Show only properties by this name\n"
                "  -a --all           Show all units/properties, including dead/empty ones\n"
                "     --replace       When installing a new job, replace existing conflicting ones\n"
                "     --system        Connect to system bus\n"
@@ -2122,7 +2129,7 @@ static int systemctl_help(void) {
                "  reload [NAME...]                Reload one or more units\n"
                "  isolate [NAME]                  Start one unit and stop all others\n"
                "  check [NAME...]                 Check whether any of the passed units are active\n"
-               "  show [NAME...|JOB...]           Show information about one or more units\n"
+               "  show [NAME...|JOB...]           Show information about one or more units/jobs/manager\n"
                "  load [NAME...]                  Load one or more units\n"
                "  list-jobs                       List jobs\n"
                "  cancel [JOB...]                 Cancel one or more jobs\n"