changeset 1639:ff794644a70a

Add --formats option to 64vw and remove the format listing from --help.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 28 May 2018 14:52:45 +0300
parents 07f27ec0801e
children e9a43ee46f71
files tools/64vw.c
diffstat 1 files changed, 27 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/tools/64vw.c	Mon May 28 14:52:24 2018 +0300
+++ b/tools/64vw.c	Mon May 28 14:52:45 2018 +0300
@@ -29,8 +29,9 @@
     { 1, 'v', "verbose",    "Be more verbose", OPT_NONE },
     { 2,   0, "fs",         "Fullscreen", OPT_NONE },
     { 3, 'S', "scale",      "Scale image by factor (1-10)", OPT_ARGREQ },
-    { 4, 'f', "format",     "Force input format (see list below)", OPT_ARGREQ },
-    { 5, 'p', "probe",      "Probe only (no display)", OPT_NONE },
+    { 4, 'f', "format",     "Force input format (see --formats)", OPT_ARGREQ },
+    { 5, 'F', "formats",    "List supported input formats", OPT_NONE },
+    { 6, 'p', "probe",      "Probe only (no display)", OPT_NONE },
 };
 
 const int optListN = sizeof(optList) / sizeof(optList[0]);
@@ -43,21 +44,29 @@
 }
 
 
+void argShowFormats()
+{
+    printf(
+    "Available C64 bitmap formats (-f <frmt>):\n"
+    " frmt | Type            | Description\n"
+    "------+-----------------+-------------------------------------\n"
+    );
+    for (int i = 0; i < ndmC64ImageFormats; i++)
+    {
+        const DMC64ImageFormat *fmt = &dmC64ImageFormats[i];
+        char buf[64];
+        printf("%-6s| %-15s | %s\n",
+            fmt->fext,
+            dmC64GetImageTypeString(buf, sizeof(buf), fmt->type, FALSE),
+            fmt->name);
+    }
+}
+
+
 void argShowHelp()
 {
     dmPrintBanner(stdout, dmProgName, "[options] <input image file>");
     dmArgsPrintHelp(stdout, optList, optListN, 0);
-
-    printf("\nAvailable bitmap formats:\n");
-    for (int i = 0; i < ndmC64ImageFormats; i++)
-    {
-        const DMC64ImageFormat *fmt = &dmC64ImageFormats[i];
-        char buf[64];
-        printf(" %-5s | %-15s | %s\n",
-            fmt->fext,
-            dmC64GetImageTypeString(buf, sizeof(buf), fmt->type, FALSE),
-            fmt->name);
-    }
 }
 
 
@@ -120,6 +129,11 @@
             break;
 
         case 5:
+            argShowFormats();
+            exit(0);
+            break;
+
+        case 6:
             if (dmVerbosity < 1)
                 dmVerbosity = 1;
             optProbeOnly = TRUE;