Index: utils/OFZIP.m ================================================================== --- utils/OFZIP.m +++ utils/OFZIP.m @@ -55,24 +55,31 @@ { [stream writeFormat: @"Usage: %@ -[flnqvx] archive.zip [file1 file2 ...]\n", [OFApplication programName]]; - if (full) { + if (full) [stream writeString: @"\nOptions:\n" @" -f Force / override files\n" @" -h Show this help\n" @" -l List all files in the archive\n" @" -n Never override files\n" @" -q Quiet mode (no output, except errors)\n" @" -v Verbose output for file list\n" @" -x Extract files\n"]; - } [OFApplication terminateWithStatus: status]; } + +static void +mutuallyExclusiveError(of_unichar_t option1, of_unichar_t option2) +{ + [of_stderr writeFormat: @"Error: -%C and -%C are mutually exclusive!\n", + option1, option2]; + [OFApplication terminateWithStatus: 1]; +} @implementation OFZIP - (void)applicationDidFinishLaunching { OFOptionsParser *optionsParser = @@ -83,25 +90,37 @@ OFArray *files; while ((option = [optionsParser nextOption]) != '\0') { switch (option) { case 'f': + if (_override < 0) + mutuallyExclusiveError('f', 'n'); + _override = 1; break; case 'n': + if (_override > 0) + mutuallyExclusiveError('f', 'n'); + _override = -1; break; case 'v': - _outputLevel = 1; + if (_outputLevel < 0) + mutuallyExclusiveError('v', 'q'); + + _outputLevel++; break; case 'q': - _outputLevel = -1; + if (_outputLevel > 0) + mutuallyExclusiveError('v', 'q'); + + _outputLevel--; break; case 'l': case 'x': if (mode != '\0') - help(of_stdout, false, 1); + mutuallyExclusiveError('x', 'l'); mode = option; break; case 'h': help(of_stdout, true, 0);