Implement basic --help option
authorWouter Verhelst <w@uter.be>
Fri, 27 May 2011 23:11:25 +0000 (01:11 +0200)
committerWouter Verhelst <w@uter.be>
Fri, 27 May 2011 23:11:25 +0000 (01:11 +0200)
nbd-trdump.c

index 49f4f9e..82b7688 100644 (file)
@@ -43,6 +43,17 @@ int main(int argc, char**argv) {
        char * ctext;
        int readfd = 0; /* stdin */
 
+       if(argc > 1) {
+               int retval=0;
+               if(strcmp(argv[1], "--help") && strcmp(argv[1], "-h")) {
+                       printf("E: unknown option %s.\n", argv[1]);
+                       retval=1;
+               }
+               printf("This is nbd-trdump, part of nbd %s.\n", PACKAGE_VERSION);
+               printf("Use: %s < transactionlog\n", argv[0]);
+               return retval;
+       }
+
        while (1) {
                /* Read a request or reply from the transaction file */
                doread(readfd, &magic, sizeof(magic));