]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Added help message to minigzip.
authorNathan Moinvaziri <nathan@nathanm.com>
Thu, 4 Jun 2020 17:58:26 +0000 (10:58 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Mon, 8 Jun 2020 12:50:46 +0000 (14:50 +0200)
test/minigzip.c

index 1ac0d5f8235f8d7b251a574eeca1b2d0f6459c6a..611391b0851a2dc308f6abba2b0cd84d96dc49ee 100644 (file)
@@ -250,20 +250,19 @@ void file_uncompress(char *file, int keep) {
         unlink(infile);
 }
 
-
-/* ===========================================================================
- * Usage:  minigzip [-c] [-d] [-f] [-h] [-r] [-1 to -9] [files...]
- *   -c : write to standard output
- *   -d : decompress
- *   -k : Keep input files
- *   -f : compress with Z_FILTERED
- *   -h : compress with Z_HUFFMAN_ONLY
- *   -R : compress with Z_RLE
- *   -F : compress with Z_FIXED
- *   -T : stored raw
- *   -A : auto detect type
- *   -0 to -9 : compression level
- */
+void show_help(void) {
+    printf("Usage: minigzip [-c] [-d] [-k] [-f|-h|-R|-F|-T] [-A] [-0 to -9] [files...]\n\n" \
+           "  -c : write to standard output\n" \
+           "  -d : decompress\n" \
+           "  -k : keep input files\n" \
+           "  -f : compress with Z_FILTERED\n" \
+           "  -h : compress with Z_HUFFMAN_ONLY\n" \
+           "  -R : compress with Z_RLE\n" \
+           "  -F : compress with Z_FIXED\n" \
+           "  -T : stored raw\n" \
+           "  -A : auto detect type\n" \
+           "  -0 to -9 : compression level\n\n");
+}
 
 int main(int argc, char *argv[]) {
     int copyout = 0;
@@ -276,6 +275,11 @@ int main(int argc, char *argv[]) {
     char *level = "6";
     char *type = "b";
 
+    if ((argc == 1) || (argc == 2 && strcmp(argv[1], "--help") == 0)) {
+        show_help();
+        return 0;
+    }
+
     prog = argv[i];
     bname = strrchr(argv[i], '/');
     if (bname)