]> git.draconx.ca Git - liblbx.git/commitdiff
lbximg: Add an option to control the output filenames.
authorNick Bowler <nbowler@draconx.ca>
Wed, 19 Jun 2013 01:07:51 +0000 (21:07 -0400)
committerNick Bowler <nbowler@draconx.ca>
Wed, 19 Jun 2013 01:21:35 +0000 (21:21 -0400)
This will be needed for postmortem analysis of test cases that extract
multiple images, since otherwise there is no easy way to prevent the
tool from overwriting the earlier outputs.

This was clearly intended to be a user setting from the start but for
some reason it was never wired up to a command-line option.

doc/man/lbximg.1
src/lbximg.c

index f3ecece9de0d1dd5f16c6d72dc02a9a6166f1d65..5f0c6ee0aa5e036a1ef07ede7a414f78e5610177 100644 (file)
@@ -64,6 +64,11 @@ inefficient and provided mainly for testing.
 Read from the specified
 .Ar path
 instead of standard input.
+.It Fl -output-prefix Ar string
+Prefix each output filename with the given string.  Filenames are produced by
+adding a frame number and file extension to the given prefix.  The default
+prefix is
+.Li out .
 .It Fl n , -no-palette
 Instead of looking up colour indices in the palette, emit a grayscale image
 where the intensity value of a pixel is equal to the palette index itself.
index 0a0057a9fedf038846587c33a591bf8ba05f8853..c88fc4e21bff29a5e14c56b3df599a06de1099b4 100644 (file)
@@ -38,6 +38,10 @@ static int verbose = 0;
 static char *outname = "out";
 static int usepalette = 1;
 
+enum {
+       OPT_PREFIX = UCHAR_MAX+1,
+};
+
 static void printusage(void)
 {
        puts("usage: lbximg [-i|-d] [-v] [-p palette_file] [-O override_file]"
@@ -332,19 +336,20 @@ int main(int argc, char **argv)
 
        static const char sopts[] = "idnvF:f:p:O:VH";
        static const struct option lopts[] = {
-               { "identify",   0, NULL, 'i' },
-               { "decode",     0, NULL, 'd' },
-               { "verbose",    0, NULL, 'v' },
-               { "file",       1, NULL, 'f' },
-               { "format",     1, NULL, 'F' },
-               { "palette",    1, NULL, 'p' },
-               { "override",   1, NULL, 'O' },
+               { "identify",      0, NULL, 'i' },
+               { "decode",        0, NULL, 'd' },
+               { "verbose",       0, NULL, 'v' },
+               { "file",          1, NULL, 'f' },
+               { "format",        1, NULL, 'F' },
+               { "palette",       1, NULL, 'p' },
+               { "override",      1, NULL, 'O' },
+               { "no-palette",    0, NULL, 'n' },
 
-               { "version",    0, NULL, 'V' },
-               { "usage",      0, NULL, 'U' },
-               { "help",       0, NULL, 'H' },
+               { "output-prefix", 1, NULL,  OPT_PREFIX },
 
-               { "no-palette", 0, NULL, 'n' },
+               { "version",       0, NULL, 'V' },
+               { "usage",         0, NULL, 'U' },
+               { "help",          0, NULL, 'H' },
 
                { 0 }
        };
@@ -385,6 +390,9 @@ int main(int argc, char **argv)
                                return EXIT_FAILURE;
                        }
                        break;
+               case OPT_PREFIX:
+                       outname = optarg;
+                       break;
                case 'V':
                        tool_version();
                        return EXIT_SUCCESS;