chiark / gitweb /
utils: show help blurb when run without any arguments
[elogind.git] / src / notify.c
index 77978104a71cd9f8789927e8a757606791e14161..514636e47208ae310d67b3c174a6406251f6bcd1 100644 (file)
@@ -39,7 +39,7 @@ static bool arg_booted = false;
 
 static int help(void) {
 
-        printf("%s [options] [VARIABLE=VALUE...]\n\n"
+        printf("%s [OPTIONS...] [VARIABLE=VALUE...]\n\n"
                "Notify the init system about service status updates.\n\n"
                "  -h --help         Show this help\n"
                "     --ready        Inform the init system about service start-up completion\n"
@@ -115,6 +115,15 @@ static int parse_argv(int argc, char *argv[]) {
                 }
         }
 
+        if (optind >= argc &&
+            !arg_ready &&
+            !arg_status &&
+            !arg_pid &&
+            !arg_booted) {
+                help();
+                return -EINVAL;
+        }
+
         return 1;
 }