@@ -503,10 +503,10 @@ int main(int argc, char *argv[])
503
503
504
504
(" ignore-case,i" , " ignore case when matching regular expressions" )
505
505
(" invert-match,v" , " select defects that do not match the selected criteria" )
506
- (" invert-regex,n" , " invert regular expressions in all predicates" )
506
+ (" invert-regex,n" , " invert regular expressions in all predicates" );
507
507
508
- ( " color " , " use colorized console output (default if connected to a terminal) " )
509
- ( " no-color " , " do not use colorized console output " )
508
+ addColorOptions (&desc);
509
+ desc. add_options ( )
510
510
(" quiet,q" , " do not report any parsing errors" )
511
511
512
512
(" mode" , po::value<string>(&mode)
@@ -547,17 +547,14 @@ int main(int argc, char *argv[])
547
547
}
548
548
549
549
// handle --[no-]color options
550
- const bool color_always = vm.count (" color" );
551
- const bool color_never = vm.count (" no-color" );
552
- if (color_always && color_never) {
553
- std::cerr << name << " : error: "
554
- " options --color and --no-color are mutually exclusive\n " ;
550
+ EColorMode cm;
551
+ const char *err;
552
+ if (readColorOptions (&cm, &err, vm))
553
+ WriterFactory::setColorMode (cm);
554
+ else {
555
+ std::cerr << name << " : error: " << err << std::endl;
555
556
return 1 ;
556
557
}
557
- if (color_always)
558
- WriterFactory::setColorMode (CM_ALWAYS);
559
- if (color_never)
560
- WriterFactory::setColorMode (CM_NEVER);
561
558
562
559
// create a writer according to the selected mode
563
560
WriterFactory factory;
0 commit comments