Commit f29d3e89671f0f97545aaf852f7c131b1ddaefdf

Stefan Sperling 2018-06-23T19:12:36

make 'tog -h' and 'tog -h xxx' show something useful

diff --git a/tog/tog.c b/tog/tog.c
index b203855..ba0c80e 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -1253,6 +1253,8 @@ main(int argc, char *argv[])
 	optreset = 1;
 
 	if (argc == 0) {
+		if (hflag)
+			usage();
 		/* Build an argument vector which runs a default command. */
 		cmd = &tog_commands[0];
 		cmd_argv = make_argv(cmd->name, NULL);
@@ -1281,6 +1283,12 @@ main(int argc, char *argv[])
 			} else
 				error = got_error_from_errno();
 			if (error) {
+				if (hflag) {
+					fprintf(stderr, "%s: '%s' is not a "
+					    "known command\n", getprogname(),
+					    argv[0]);
+					usage();
+				}
 				fprintf(stderr, "%s: '%s' is neither a known "
 				    "command nor a path to a repository\n",
 				    getprogname(), argv[0]);