]> git.draconx.ca Git - liblbx.git/commitdiff
Add version, help, and usage messages to the tools.
authorNick Bowler <draconx@gmail.com>
Sat, 5 Jan 2008 07:31:30 +0000 (02:31 -0500)
committerNick Bowler <draconx@gmail.com>
Sat, 5 Jan 2008 07:34:11 +0000 (02:34 -0500)
doc/man/lbximg.1
doc/man/lbxtool.1
src/Makefile.am
src/lbximg.c
src/lbxtool.c

index cebcef74fcda32e3a86cc07141a8aba641f435b6..564655b8b1f42aa9126671f7fb46d3fb1fc54b86 100644 (file)
@@ -49,6 +49,12 @@ Use the embedded palette of an LBX image specified by
 as the override palette.  In Moo2, this is notably used to select the player
 colour for ship images.  Colours in the override palette supersede those in
 both the base palette and the embedded palette.
+.It Fl V , -version
+Print a version message and exit.
+.It Fl -usage
+Print a short usage message and exit.
+.It Fl -help
+Print a help message and exit
 .It Ar frameno ...
 Specifies the frames to decode as a sequence of intervals, with frames indexing
 from zero.  By default, all frames are decoded.  Multiplicity is ignored, as is
index a5ac3191f4e4e9925640a3d4085d133f9ae23eee..c91a96953f0a0b825c37d9a6b000ba748a3baa7c 100644 (file)
@@ -31,6 +31,12 @@ instead of standard input.  If
 is -,
 .Nm
 will read from standard input anyway.
+.It Fl V , -version
+Print a version message and exit.
+.It Fl -usage
+Print a short usage message and exit.
+.It Fl -help
+Print a help message and exit
 .It Ar
 Limit the operation to these files in the archive.  By default, all files are
 selected.  Supports common shell globbing features.
index ab54c5a0841577544bcdf27f78701bad5bc94aa8..3736bd82cb823c60076bd04ccf19c29130269249 100644 (file)
@@ -6,11 +6,11 @@ lbx_HEADERS   = lbx.h image.h
 
 liblbx_la_SOURCES = byteorder.h misc.h misc.c lbx.c image.c
 
-lbxtool_SOURCES   = lbxtool.c
+lbxtool_SOURCES   = tools.h lbxtool.c
 lbxtool_LDADD     = liblbx.la
 
 if BUILD_LBXIMG
-lbximg_SOURCES    = lbximg.c
+lbximg_SOURCES    = tools.h lbximg.c
 lbximg_LDADD      = liblbx.la
 lbximg_CFLAGS     = $(PNG_CFLAGS)
 lbximg_LDFLAGS    = $(PNG_LIBS)
index 61516196174999a7aab25ca0f9428699184845ff..d56824c073389b1800ed65c55c8534bff0ca3df0 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <png.h>
 
+#include "tools.h"
 #include "image.h"
 #include "lbx.h"
 
@@ -35,6 +36,19 @@ static int verbose = 0;
 static char *outname = "out";
 static int usepalette = 1;
 
+static void printusage(void)
+{
+       puts("usage: lbximg [-i|-d] [-v] [-p palette_file] [-O override_file]"
+                         " [-f path]");
+       puts("              [frameno ...]");
+}
+
+static void printhelp(void)
+{
+       printusage();
+       puts("For now, see the man page for detailed help.");
+}
+
 static const char *progname;
 #define errmsg(fmt, ...) (\
        fprintf(stderr, "%s: " fmt, progname, __VA_ARGS__)\
@@ -356,7 +370,7 @@ int main(int argc, char **argv)
        LBX_IMG *img;
        int opt;
 
-       static const char *sopts = "idvf:p:O:";
+       static const char *sopts = "idvf:p:O:V";
        static const struct option lopts[] = {
                { "ident",    0, NULL, 'i' },
                { "decode",   0, NULL, 'd' },
@@ -365,6 +379,10 @@ int main(int argc, char **argv)
                { "palette",  1, NULL, 'p' },
                { "override", 1, NULL, 'p' },
 
+               { "version",  0, NULL, 'V' },
+               { "usage",    0, NULL, 'U' },
+               { "help",     0, NULL, 'H' },
+
                { "nopalette", 0, &usepalette, 0 },
 
                { 0 }
@@ -410,6 +428,15 @@ int main(int argc, char **argv)
                                return EXIT_FAILURE;
                        }
                        break;
+               case 'V':
+                       puts(VERSION_BOILERPLATE("lbximg"));
+                       return EXIT_SUCCESS;
+               case 'U':
+                       printusage();
+                       return EXIT_SUCCESS;
+               case 'H':
+                       printhelp();
+                       return EXIT_SUCCESS;
                case '?':
                case ':':
                        return EXIT_FAILURE;
index 2c6105bea5d99d0a235ed937c67d1fef7beb3a75..1d80eeb0bcc5ab2c075b2c20ed5c0e33ce49745e 100644 (file)
 #include <getopt.h>
 #include <fnmatch.h>
 
+#include "tools.h"
 #include "lbx.h"
 
+static void printusage(void)
+{
+       puts("usage: lbxtool [-l|-x] [-v] [-f path] [file ...]");
+}
+
+static void printhelp(void)
+{
+       printusage();
+       puts("For now, see the man page for detailed help.");
+}
+
 static const char *progname;
 #define errmsg(fmt, ...) (\
        fprintf(stderr, "%s: " fmt, progname, __VA_ARGS__)\
@@ -159,7 +171,7 @@ int main(int argc, char **argv)
        FILE *f  = stdin;
        int opt;
 
-       static const char         *sopts   = "lxf:i:v";
+       static const char         *sopts   = "lxf:i:vV";
        static const struct option lopts[] = {
                { "list",    0, NULL, 'l' },
                { "extract", 0, NULL, 'x' },
@@ -169,6 +181,10 @@ int main(int argc, char **argv)
 
                { "verbose", 0, NULL, 'v' },
 
+               { "version", 0, NULL, 'V' },
+               { "usage",   0, NULL, 'U' },
+               { "help",    0, NULL, 'H' },
+
                { 0 }
        };
 
@@ -200,6 +216,15 @@ int main(int argc, char **argv)
                case 'v':
                        verbose = 1;
                        break;
+               case 'V':
+                       puts(VERSION_BOILERPLATE("lbxtool"));
+                       return EXIT_SUCCESS;
+               case 'U':
+                       printusage();
+                       return EXIT_SUCCESS;
+               case 'H':
+                       printhelp();
+                       return EXIT_SUCCESS;
                default:
                        return EXIT_FAILURE;
                }