added program version

Wed, 02 Jul 2014 15:09:17 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 02 Jul 2014 15:09:17 +0200
changeset 52
26707039d5a6
parent 51
84f2e380a434
child 53
78b580bfde33

added program version

src/main.c file | annotate | diff | comparison | revisions
src/terminal-chess.h file | annotate | diff | comparison | revisions
--- a/src/main.c	Mon Jun 16 15:41:06 2014 +0200
+++ b/src/main.c	Wed Jul 02 15:09:17 2014 +0200
@@ -41,7 +41,7 @@
     uint8_t timeunit = 60;
     size_t len;
     
-    for (int opt ; (opt = getopt(argc, argv, "a:bc:hp:rsS:t:")) != -1 ;) {
+    for (int opt ; (opt = getopt(argc, argv, "a:bc:hp:rsS:t:v")) != -1 ;) {
         switch (opt) {
         case 'c':
             settings->continuepgn = optarg;
@@ -92,10 +92,35 @@
                 settings->port = optarg;
             }
             break;
+        case 'v':
+            printf("terminal-chess : Version %s (Netcode Version %d)\n",
+                PROGRAM_VERSION, NETCODE_VERSION);
+            exit(0);
         case 'h':
         case '?':
-            settings->printhelp = 1;
-            break;
+            printf(
+"Usage: terminal-chess [OPTION]... [HOST]\n"
+"Starts/joins a network chess game\n"
+"\nGeneral options\n"
+"  -c <PGN file> Continue the specified game\n"
+"  -h            This help page\n"
+"  -p            TCP port to use (default: 27015)\n"
+// TODO: implement and activate feature
+//"  -S <PGN file> Compute and print statistics for the specified game\n"
+"  -v            Print version information and exists\n"
+"\nServer options\n"
+"  -a <time>     Specifies the time to add after each move\n"
+"  -b            Server plays black pieces (default: white)\n"
+"  -r            Distribute color randomly\n"
+"  -s            Single machine mode\n"
+"  -t <time>     Specifies time limit (default: no limit)\n"
+"\nNotes\n"
+"The time unit for -a is seconds and for -t minutes by default. To "
+"specify\nseconds for the -t option, use the s suffix.\n"
+"Example: -t 150s\n\n"
+"Use '-' for PGN files to read PGN data from standard input\n"
+            );
+            exit(0);
         }
     }
     
@@ -180,31 +205,7 @@
     if (get_settings(argc, argv, &settings)) {
         return 1;
     }
-    
-    if (settings.printhelp) {
-        printf(
-"Usage: terminal-chess [OPTION]... [HOST]\n"
-"Starts/joins a network chess game\n"
-"\nGeneral options\n"
-"  -c <PGN file> Continue the specified game\n"
-"  -h            This help page\n"
-"  -p            TCP port to use (default: 27015)\n"
-// TODO: implement and activate feature
-//"  -S <PGN file> Compute and print statistics for the specified game\n"
-"\nServer options\n"
-"  -a <time>     Specifies the time to add after each move\n"
-"  -b            Server plays black pieces (default: white)\n"
-"  -r            Distribute color randomly\n"
-"  -s            Single machine mode\n"
-"  -t <time>     Specifies time limit (default: no limit)\n"
-"\nNotes\n"
-"The time unit for -a is seconds and for -t minutes by default. To "
-"specify\nseconds for the -t option, use the s suffix.\n"
-"Example: -t 150s\n\n"
-"Use '-' for PGN files to read PGN data from standard input\n"
-        );
-        return EXIT_SUCCESS;
-    }    
+
     initscr();
     halfdelay(1);
     keypad(stdscr, TRUE);
--- a/src/terminal-chess.h	Mon Jun 16 15:41:06 2014 +0200
+++ b/src/terminal-chess.h	Wed Jul 02 15:09:17 2014 +0200
@@ -36,6 +36,8 @@
 #ifndef TERMINAL_CHESS_H
 #define	TERMINAL_CHESS_H
 
+#define PROGRAM_VERSION "0.9-r52"
+
 #ifdef	__cplusplus
 extern "C" {
 #endif
@@ -46,7 +48,6 @@
     char* serverhost; /* NULL, if we are about to start a server */
     char* continuepgn;
     char* analyzepgn;
-    _Bool printhelp;
     _Bool singlemachine;
 } Settings;
 

mercurial