src/main.c

changeset 52
26707039d5a6
parent 51
84f2e380a434
child 55
54ea19938d57
equal deleted inserted replaced
51:84f2e380a434 52:26707039d5a6
39 char *valid; 39 char *valid;
40 unsigned long int time, port; 40 unsigned long int time, port;
41 uint8_t timeunit = 60; 41 uint8_t timeunit = 60;
42 size_t len; 42 size_t len;
43 43
44 for (int opt ; (opt = getopt(argc, argv, "a:bc:hp:rsS:t:")) != -1 ;) { 44 for (int opt ; (opt = getopt(argc, argv, "a:bc:hp:rsS:t:v")) != -1 ;) {
45 switch (opt) { 45 switch (opt) {
46 case 'c': 46 case 'c':
47 settings->continuepgn = optarg; 47 settings->continuepgn = optarg;
48 break; 48 break;
49 case 'b': 49 case 'b':
90 return 1; 90 return 1;
91 } else { 91 } else {
92 settings->port = optarg; 92 settings->port = optarg;
93 } 93 }
94 break; 94 break;
95 case 'v':
96 printf("terminal-chess : Version %s (Netcode Version %d)\n",
97 PROGRAM_VERSION, NETCODE_VERSION);
98 exit(0);
95 case 'h': 99 case 'h':
96 case '?': 100 case '?':
97 settings->printhelp = 1; 101 printf(
98 break; 102 "Usage: terminal-chess [OPTION]... [HOST]\n"
103 "Starts/joins a network chess game\n"
104 "\nGeneral options\n"
105 " -c <PGN file> Continue the specified game\n"
106 " -h This help page\n"
107 " -p TCP port to use (default: 27015)\n"
108 // TODO: implement and activate feature
109 //" -S <PGN file> Compute and print statistics for the specified game\n"
110 " -v Print version information and exists\n"
111 "\nServer options\n"
112 " -a <time> Specifies the time to add after each move\n"
113 " -b Server plays black pieces (default: white)\n"
114 " -r Distribute color randomly\n"
115 " -s Single machine mode\n"
116 " -t <time> Specifies time limit (default: no limit)\n"
117 "\nNotes\n"
118 "The time unit for -a is seconds and for -t minutes by default. To "
119 "specify\nseconds for the -t option, use the s suffix.\n"
120 "Example: -t 150s\n\n"
121 "Use '-' for PGN files to read PGN data from standard input\n"
122 );
123 exit(0);
99 } 124 }
100 } 125 }
101 126
102 if (optind == argc - 1) { 127 if (optind == argc - 1) {
103 settings->serverhost = argv[optind]; 128 settings->serverhost = argv[optind];
178 203
179 Settings settings = default_settings(); 204 Settings settings = default_settings();
180 if (get_settings(argc, argv, &settings)) { 205 if (get_settings(argc, argv, &settings)) {
181 return 1; 206 return 1;
182 } 207 }
183 208
184 if (settings.printhelp) {
185 printf(
186 "Usage: terminal-chess [OPTION]... [HOST]\n"
187 "Starts/joins a network chess game\n"
188 "\nGeneral options\n"
189 " -c <PGN file> Continue the specified game\n"
190 " -h This help page\n"
191 " -p TCP port to use (default: 27015)\n"
192 // TODO: implement and activate feature
193 //" -S <PGN file> Compute and print statistics for the specified game\n"
194 "\nServer options\n"
195 " -a <time> Specifies the time to add after each move\n"
196 " -b Server plays black pieces (default: white)\n"
197 " -r Distribute color randomly\n"
198 " -s Single machine mode\n"
199 " -t <time> Specifies time limit (default: no limit)\n"
200 "\nNotes\n"
201 "The time unit for -a is seconds and for -t minutes by default. To "
202 "specify\nseconds for the -t option, use the s suffix.\n"
203 "Example: -t 150s\n\n"
204 "Use '-' for PGN files to read PGN data from standard input\n"
205 );
206 return EXIT_SUCCESS;
207 }
208 initscr(); 209 initscr();
209 halfdelay(1); 210 halfdelay(1);
210 keypad(stdscr, TRUE); 211 keypad(stdscr, TRUE);
211 if (has_colors()) { 212 if (has_colors()) {
212 start_color(); 213 start_color();

mercurial