Skip to content

Commit

Permalink
max-msg arg error and help message improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
RosscoG committed Nov 30, 2024
1 parent cb3d59a commit a019e27
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions include/acutest.h
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,7 @@ acutest_help_(void)
printf(" 2 ... As 1 and failed conditions (this is default)\n");
printf(" 3 ... As 1 and all conditions (and extended summary)\n");
printf(" -q, --quiet Same as --verbose=0\n");
printf(" --max-msg=NUMBER Set output limit to NUMBER\n");
printf(" --max-msg=NUMBER Set message output limit to NUMBER (greater than 0)\n");
printf(" --color[=WHEN] Enable colorized output\n");
printf(" (WHEN is one of 'auto', 'always', 'never')\n");
printf(" --no-color Same as --color=never\n");
Expand Down Expand Up @@ -1573,7 +1573,7 @@ static const ACUTEST_CMDLINE_OPTION_ acutest_cmdline_options_[] = {
{ 'l', "list", 'l', 0 },
{ 'v', "verbose", 'v', ACUTEST_CMDLINE_OPTFLAG_OPTIONALARG_ },
{ 'q', "quiet", 'q', 0 },
{ 0, "max-msg", 'm', ACUTEST_CMDLINE_OPTFLAG_OPTIONALARG_ },
{ 0, "max-msg", 'm', ACUTEST_CMDLINE_OPTFLAG_REQUIREDARG_ },
{ 0, "color", 'c', ACUTEST_CMDLINE_OPTFLAG_OPTIONALARG_ },
{ 0, "no-color", 'C', 0 },
{ 'h', "help", 'h', 0 },
Expand Down Expand Up @@ -1646,7 +1646,12 @@ acutest_cmdline_callback_(int id, const char* arg)
break;

case 'm':
acutest_max_msg_ = (arg != NULL ? atoi(arg) : acutest_max_msg_);
acutest_max_msg_ = atoi(arg);
if (acutest_max_msg_ < 1) {
fprintf(stderr, "%s: Argument error '%s' for option --max-msg.\n", acutest_argv0_, arg);
fprintf(stderr, "Try '%s --help' for more information.\n", acutest_argv0_);
acutest_exit_(2);
}
break;

case 'c':
Expand Down

0 comments on commit a019e27

Please sign in to comment.