mirror of
https://git.zap.org.au/git/trader.git
synced 2024-12-04 14:46:45 -05:00
Add the --no-color (and --no-colour) command-line options
This commit is contained in:
parent
3093e2cfd3
commit
546c80053f
@ -72,3 +72,5 @@ int game_num = 0; // Game number (1-9)
|
|||||||
|
|
||||||
bool quit_selected; // Is a player trying to quit the game?
|
bool quit_selected; // Is a player trying to quit the game?
|
||||||
bool abort_game; // Abort game without declaring winner?
|
bool abort_game; // Abort game without declaring winner?
|
||||||
|
|
||||||
|
bool option_no_color = false; // True if --no-color was specified
|
||||||
|
@ -150,5 +150,7 @@ extern int game_num; // Game number (1-9)
|
|||||||
extern bool quit_selected; // Is a player trying to quit the game?
|
extern bool quit_selected; // Is a player trying to quit the game?
|
||||||
extern bool abort_game; // Abort game without declaring winner?
|
extern bool abort_game; // Abort game without declaring winner?
|
||||||
|
|
||||||
|
extern bool option_no_color; // True if --no-color was specified
|
||||||
|
|
||||||
|
|
||||||
#endif /* included_GLOBALS_H */
|
#endif /* included_GLOBALS_H */
|
||||||
|
@ -29,8 +29,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include "intf.h"
|
#include "trader.h"
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
@ -88,7 +87,7 @@ void init_screen (void)
|
|||||||
MIN_COLS, MIN_LINES);
|
MIN_COLS, MIN_LINES);
|
||||||
}
|
}
|
||||||
|
|
||||||
use_color = has_colors();
|
use_color = ! option_no_color && has_colors();
|
||||||
|
|
||||||
curwin = stdscr;
|
curwin = stdscr;
|
||||||
topwin = NULL;
|
topwin = NULL;
|
||||||
|
29
src/trader.c
29
src/trader.c
@ -68,7 +68,6 @@ int main (int argc, char *argv[])
|
|||||||
init_program();
|
init_program();
|
||||||
|
|
||||||
// Play the actual game
|
// Play the actual game
|
||||||
|
|
||||||
init_game();
|
init_game();
|
||||||
while (! quit_selected && ! abort_game && turn_number <= max_turn) {
|
while (! quit_selected && ! abort_game && turn_number <= max_turn) {
|
||||||
select_moves();
|
select_moves();
|
||||||
@ -91,15 +90,21 @@ int main (int argc, char *argv[])
|
|||||||
|
|
||||||
/* Constants for command line options */
|
/* Constants for command line options */
|
||||||
|
|
||||||
|
enum options_char {
|
||||||
|
OPTION_NO_COLOR = 1,
|
||||||
|
};
|
||||||
|
|
||||||
static const char options_short[] = "hV";
|
static const char options_short[] = "hV";
|
||||||
/* -h --help
|
/* -h --help
|
||||||
-V --version
|
-V --version
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static struct option const options_long[] = {
|
static struct option const options_long[] = {
|
||||||
{ "help", no_argument, NULL, 'h' },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
{ "version", no_argument, NULL, 'V' },
|
{ "version", no_argument, NULL, 'V' },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ "no-color", no_argument, NULL, OPTION_NO_COLOR },
|
||||||
|
{ "no-colour", no_argument, NULL, OPTION_NO_COLOR },
|
||||||
|
{ NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -126,12 +131,19 @@ void process_cmdline (int argc, char *argv[])
|
|||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'h':
|
case 'h':
|
||||||
/* -h, --help: show help */
|
// -h, --help: show help
|
||||||
show_usage(EXIT_SUCCESS);
|
show_usage(EXIT_SUCCESS);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'V':
|
case 'V':
|
||||||
/* -V, --version: show version information */
|
// -V, --version: show version information
|
||||||
show_version();
|
show_version();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OPTION_NO_COLOR:
|
||||||
|
// --no-color, --no-colour: don't use colour
|
||||||
|
option_no_color = true;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
show_usage(EXIT_FAILURE);
|
show_usage(EXIT_FAILURE);
|
||||||
@ -219,8 +231,9 @@ Play Star Traders, a simple game of interstellar trading.\n\n\
|
|||||||
");
|
");
|
||||||
printf("\
|
printf("\
|
||||||
Options:\n\
|
Options:\n\
|
||||||
-V, --version output version information and exit\n\
|
-V, --version output version information and exit\n\
|
||||||
-h, --help display this help and exit\n\n\
|
-h, --help display this help and exit\n\
|
||||||
|
--no-color don't use colour for displaying text\n\n\
|
||||||
");
|
");
|
||||||
printf("\
|
printf("\
|
||||||
If GAME is specified as a number between 1 and 9, load and continue\n\
|
If GAME is specified as a number between 1 and 9, load and continue\n\
|
||||||
|
Loading…
Reference in New Issue
Block a user