1- // $Id: cheops.cpp,v 1.5 2003-12-06 17 :43:11 psy Exp $
1+ // $Id: cheops.cpp,v 1.6 2003-12-07 19 :43:33 psy Exp $
22//
33// cheops.cpp : Defines the entry point for the console application.
44//
3535void show_menu (void );
3636move *parse_move (const string& s);
3737void who_plays (Player *&w, Player *&b);
38+ void show_help (void );
39+ void show_version (void );
3840
3941int main (int argc, char * argv[]) {
4042
@@ -45,17 +47,36 @@ int main(int argc, char* argv[]) {
4547 move *m = NULL ;
4648 int turn=0 ;
4749
50+ // Process command-line parameters
51+ while (argc-- > 1 ) {
52+ argv++;
53+ if (strcmp (*argv, " --help" ) == 0 ) {
54+ show_help ();
55+ exit (0 );
56+ }
57+ else if (strcmp (*argv, " --version" ) == 0 ) {
58+ show_version ();
59+ exit (0 );
60+ }
61+ else {
62+ cerr << " cheops: unrecognized option `" << argv[0 ] << " '\n " ;
63+ show_help ();
64+ exit (1 );
65+ }
66+ }
67+
4868 // Print title screen
49- cout << " \t\t\t __ __\n "
50- " \t\t\t\\ \\ / / Cheops v1.0\n "
51- " \t\t\t \\ v / ___ ___ _ _ _\n "
52- " \t\t\t > < / __) _ \\ | || || |\n "
53- " \t\t\t / ^ \\ > _| (_) ) \\ | |/ |\n "
54- " \t\t\t /_/ \\ _\\ ___)___/ \\ _ _/\n "
55- " \t\t\t _________________| |__\n "
56- " \t\t\t (_________________|_|__)\n\n "
57- " \t\t\t Copyright (C) 1999, 2000 Tristan Miller\n "
58- " \t\t\t http://www.nothingisreal.com/cheops/\n\n " ;
69+ show_version ();
70+ cout <<
71+ " \t\t\t __ __\n "
72+ " \t\t\t\\ \\ / /\n "
73+ " \t\t\t \\ v / ___ ___ _ _ _\n "
74+ " \t\t\t > < / __) _ \\ | || || |\n "
75+ " \t\t\t / ^ \\ > _| (_) ) \\ | |/ |\n "
76+ " \t\t\t /_/ \\ _\\ ___)___/ \\ _ _/\n "
77+ " \t\t\t _________________| |__\n "
78+ " \t\t\t (_________________|_|__)\n\n "
79+ ;
5980
6081 who_plays (w_player, b_player);
6182
@@ -273,3 +294,21 @@ void who_plays(Player *&w, Player *&b) {
273294 b->set_stats ();
274295 }
275296}
297+
298+ void show_help (void ) {
299+ cerr <<
300+ " Usage: cheops [options]\n "
301+ " Options:\n "
302+ " --help Display this information and exit\n "
303+ " --version Display version information and exit\n "
304+ ;
305+ }
306+
307+ void show_version (void ) {
308+ cout <<
309+ PACKAGE_STRING " \n "
310+ " Copyright (C) 1999, 2000, 2003 Tristan Miller\n "
311+ " This is free software; see the source for copying conditions. There is NO\n "
312+ " warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n "
313+ ;
314+ }
0 commit comments