Allow synonyms for help and print same message as OSX for unrecognised option

This commit is contained in:
Richard Frith-Macdonald 2020-11-12 06:46:55 +00:00
parent d342c4a459
commit d1bd406e17

View file

@ -501,12 +501,12 @@ main(int argc, char **argv, char **env)
// clang-format on // clang-format on
NS_DURING NS_DURING
{ {
NSData * fileData; NSData *fileData;
NSPropertyListFormat aFormat; NSPropertyListFormat aFormat;
NSError * anError; NSError *anError;
id result; id result;
NSMutableString * outStr = nil; NSMutableString *outStr = nil;
NSDictionary * locale; NSDictionary *locale;
arg = [args objectAtIndex: i]; arg = [args objectAtIndex: i];
if (![arg hasPrefix: @"-"]) if (![arg hasPrefix: @"-"])
@ -538,7 +538,9 @@ main(int argc, char **argv, char **env)
{ {
goto parse_file; goto parse_file;
} }
else if ([arg isEqual: @"-help"]) else if ([arg caseInsensitiveCompare: @"-help"] == NSOrderedSame
|| [arg caseInsensitiveCompare: @"--help"] == NSOrderedSame
|| [arg caseInsensitiveCompare: @"-h"] == NSOrderedSame)
{ {
print_help(stdout); print_help(stdout);
break; break;
@ -557,8 +559,8 @@ main(int argc, char **argv, char **env)
} }
else else
{ {
[NSException raise: NSInvalidArgumentException GSPrintf(stderr, @"unrecognized option: %@\n", arg);
format: @"Invalid option %@", arg]; return EXIT_FAILURE;
} }
} }