chiark / gitweb /
timedatectl,hostnamectl: rework --help text
[elogind.git] / src / timedate / timedatectl.c
index 8c6e7c9212100e2651ec28e49336e5537b733129..2b006ce924a552cf1577d265cce4c4a2d648ffa2 100644 (file)
@@ -34,7 +34,7 @@
 #include "strv.h"
 #include "pager.h"
 
-static bool arg_fix_system = false;
+static bool arg_adjust_system_clock = false;
 static bool arg_no_pager = false;
 static enum transport {
         TRANSPORT_NORMAL,
@@ -69,11 +69,9 @@ typedef struct StatusInfo {
 } StatusInfo;
 
 static bool ntp_synced(void) {
-
         struct timex txc;
 
         zero(txc);
-
         if (adjtimex(&txc) < 0)
                 return false;
 
@@ -90,6 +88,8 @@ static void print_status_info(StatusInfo *i) {
         time_t sec;
         int r;
 
+        assert(i);
+
         n = now(CLOCK_REALTIME);
         sec = (time_t) (n / USEC_PER_SEC);
 
@@ -191,6 +191,7 @@ static int show_status(DBusConnection *bus, char **args, unsigned n) {
                 return -EIO;
         }
 
+        zero(info);
         dbus_message_iter_recurse(&iter, &sub);
 
         while (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_INVALID) {
@@ -301,7 +302,7 @@ static int set_local_rtc(DBusConnection *bus, char **args, unsigned n) {
         }
 
         b = r;
-        q = arg_fix_system;
+        q = arg_adjust_system_clock;
 
         return bus_method_call_with_reply(
                         bus,
@@ -357,7 +358,7 @@ static int zone_compare(const void *_a, const void *_b) {
 static int list_timezones(DBusConnection *bus, char **args, unsigned n) {
         _cleanup_fclose_ FILE *f = NULL;
         _cleanup_strv_free_ char **zones = NULL;
-        size_t n_zones;
+        size_t n_zones = 0;
         char **i;
 
         assert(args);
@@ -429,21 +430,22 @@ static int list_timezones(DBusConnection *bus, char **args, unsigned n) {
 
 static int help(void) {
 
-        printf("%s [OPTIONS...] {COMMAND} ...\n\n"
-               "Query or control system time and date settings.\n\n"
+        printf("%s [OPTIONS...] COMMAND ...\n\n"
+               "Query or change system time and date settings.\n\n"
                "  -h --help              Show this help\n"
                "     --version           Show package version\n"
-               "     --fix-system        Adjust system clock when changing local RTC mode\n"
+               "     --adjust-system-clock\n"
+               "                         Adjust system clock when changing local RTC mode\n"
                "     --no-pager          Do not pipe output into a pager\n"
                "     --no-ask-password   Do not prompt for password\n"
                "  -H --host=[USER@]HOST  Operate on remote host\n\n"
                "Commands:\n"
-               "  status                          Show current time settings\n"
-               "  set-time [TIME]                 Set system time\n"
-               "  set-timezone [ZONE]             Set system timezone\n"
-               "  list-timezones                  Show known timezones\n"
-               "  set-local-rtc [BOOL]            Control whether RTC is in local time\n"
-               "  set-ntp [BOOL]                  Control whether NTP is enabled\n",
+               "  status                 Show current time settings\n"
+               "  set-time TIME          Set system time\n"
+               "  set-timezone ZONE      Set system timezone\n"
+               "  list-timezones         Show known timezones\n"
+               "  set-local-rtc BOOL     Control whether RTC is in local time\n"
+               "  set-ntp BOOL           Control whether NTP is enabled\n",
                program_invocation_short_name);
 
         return 0;
@@ -454,19 +456,19 @@ static int parse_argv(int argc, char *argv[]) {
         enum {
                 ARG_VERSION = 0x100,
                 ARG_NO_PAGER,
-                ARG_FIX_SYSTEM,
+                ARG_ADJUST_SYSTEM_CLOCK,
                 ARG_NO_ASK_PASSWORD
         };
 
         static const struct option options[] = {
-                { "help",            no_argument,       NULL, 'h'                 },
-                { "version",         no_argument,       NULL, ARG_VERSION         },
-                { "no-pager",        no_argument,       NULL, ARG_NO_PAGER        },
-                { "host",            required_argument, NULL, 'H'                 },
-                { "privileged",      no_argument,       NULL, 'P'                 },
-                { "no-ask-password", no_argument,       NULL, ARG_NO_ASK_PASSWORD },
-                { "fix-system",      no_argument,       NULL, ARG_FIX_SYSTEM      },
-                { NULL,              0,                 NULL, 0                   }
+                { "help",                no_argument,       NULL, 'h'                     },
+                { "version",             no_argument,       NULL, ARG_VERSION             },
+                { "no-pager",            no_argument,       NULL, ARG_NO_PAGER            },
+                { "host",                required_argument, NULL, 'H'                     },
+                { "privileged",          no_argument,       NULL, 'P'                     },
+                { "no-ask-password",     no_argument,       NULL, ARG_NO_ASK_PASSWORD     },
+                { "adjust-system-clock", no_argument,       NULL, ARG_ADJUST_SYSTEM_CLOCK },
+                { NULL,                  0,                 NULL, 0                       }
         };
 
         int c;
@@ -474,7 +476,7 @@ static int parse_argv(int argc, char *argv[]) {
         assert(argc >= 0);
         assert(argv);
 
-        while ((c = getopt_long(argc, argv, "+hp:as:H:P", options, NULL)) >= 0) {
+        while ((c = getopt_long(argc, argv, "+hH:P", options, NULL)) >= 0) {
 
                 switch (c) {
 
@@ -497,8 +499,8 @@ static int parse_argv(int argc, char *argv[]) {
                         arg_host = optarg;
                         break;
 
-                case ARG_FIX_SYSTEM:
-                        arg_fix_system = true;
+                case ARG_ADJUST_SYSTEM_CLOCK:
+                        arg_adjust_system_clock = true;
                         break;
 
                 case ARG_NO_PAGER: