changeset 2539:0fda0c7e7f1c

Show help when there's an argument error or nothing to do.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 26 Dec 2023 02:43:28 +0200
parents 2198c5e6dd62
children 4ad4b890ed21
files src/colormap.c src/combine.c src/diffmap.c src/map2ppm.c src/mapstats.c src/mkcitymap.c src/mkloc.c src/patchmap.c
diffstat 8 files changed, 19 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/colormap.c	Tue Dec 26 02:40:40 2023 +0200
+++ b/src/colormap.c	Tue Dec 26 02:43:28 2023 +0200
@@ -756,7 +756,8 @@
 
     if (inFilename == NULL)
     {
-        THERR("Nothing to do. (try --help)\n");
+        argShowHelp();
+        THERR("Nothing to do.\n");
         res = 1;
         goto out;
     }
--- a/src/combine.c	Tue Dec 26 02:40:40 2023 +0200
+++ b/src/combine.c	Tue Dec 26 02:43:28 2023 +0200
@@ -245,7 +245,8 @@
 
     if (nsrcFiles < 1)
     {
-        THERR("Nothing to do. (try --help)\n");
+        argShowHelp();
+        THERR("Nothing to do.\n");
         res = 1;
         goto out;
     }
--- a/src/diffmap.c	Tue Dec 26 02:40:40 2023 +0200
+++ b/src/diffmap.c	Tue Dec 26 02:43:28 2023 +0200
@@ -202,7 +202,8 @@
 
     if (srcFilename1 == NULL || srcFilename2 == NULL)
     {
-        THERR("Nothing to do. (try --help)\n");
+        argShowHelp();
+        THERR("Nothing to do.\n");
         res = 1;
         goto out;
     }
--- a/src/map2ppm.c	Tue Dec 26 02:40:40 2023 +0200
+++ b/src/map2ppm.c	Tue Dec 26 02:43:28 2023 +0200
@@ -367,7 +367,8 @@
 
     if (srcFilename == NULL)
     {
-        THERR("Nothing to do. (try --help)\n");
+        argShowHelp();
+        THERR("Nothing to do.\n");
         res = 1;
         goto out;
     }
--- a/src/mapstats.c	Tue Dec 26 02:40:40 2023 +0200
+++ b/src/mapstats.c	Tue Dec 26 02:43:28 2023 +0200
@@ -226,7 +226,8 @@
 
     if (nsrcFilenames == 0)
     {
-        THERR("Nothing to do. (try --help)\n");
+        argShowHelp();
+        THERR("Nothing to do.\n");
         res = 1;
         goto out;
     }
--- a/src/mkcitymap.c	Tue Dec 26 02:40:40 2023 +0200
+++ b/src/mkcitymap.c	Tue Dec 26 02:43:28 2023 +0200
@@ -391,7 +391,8 @@
 
     if (optMapFilename == NULL || optLocFilename == NULL)
     {
-        THERR("You need to specify at least map and loc filenames. (try --help)\n");
+        argShowHelp();
+        THERR("You need to specify at least map and loc filenames.\n");
         res = 1;
         goto out;
     }
--- a/src/mkloc.c	Tue Dec 26 02:40:40 2023 +0200
+++ b/src/mkloc.c	Tue Dec 26 02:43:28 2023 +0200
@@ -1163,6 +1163,7 @@
     // Check the mode and arguments
     if (optInFilename == NULL && optGetUpdateLoc && optOutput == OUTFMT_LOCFILE)
     {
+        argShowHelp();
         THERR("Map file required for location update mode!\n");
         res = 1;
         goto out;
@@ -1170,6 +1171,7 @@
 
     if (optOutput == OUTFMT_LOCFILE && noptLocFiles < 0 && !optGetUpdateLoc)
     {
+        argShowHelp();
         THERR("Location file or location update mode required for location file output!\n");
         res = 1;
         goto out;
@@ -1177,6 +1179,7 @@
 
     if ((optOutput == OUTFMT_SCRIPT || optOutput == OUTFMT_MAPLOC) && noptLocFiles < 0)
     {
+        argShowHelp();
         THERR("Location file required for script or MapLoc HTML output!\n");
         res = 1;
         goto out;
@@ -1184,7 +1187,8 @@
 
     if (optInFilename == NULL && optOutput == OUTFMT_MAP)
     {
-        THERR("Mapfile required for map generation.\n");
+        argShowHelp();
+        THERR("Map file required for map generation.\n");
         res = 1;
         goto out;
     }
--- a/src/patchmap.c	Tue Dec 26 02:40:40 2023 +0200
+++ b/src/patchmap.c	Tue Dec 26 02:43:28 2023 +0200
@@ -111,7 +111,8 @@
 
     if (mapFilename == NULL || patchFilename == NULL)
     {
-        THERR("Nothing to do. (try --help)\n");
+        argShowHelp();
+        THERR("Nothing to do.\n");
         res = 1;
         goto out;
     }