mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-10 08:10:49 +00:00
Allow synonyms for help and print same message as OSX for unrecognised option
This commit is contained in:
parent
d342c4a459
commit
d1bd406e17
1 changed files with 17 additions and 15 deletions
|
@ -491,22 +491,22 @@ main(int argc, char **argv, char **env)
|
||||||
// clang-format off
|
// clang-format off
|
||||||
commands = [NSDictionary dictionaryWithObjectsAndKeys:
|
commands = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
NARRAY(NINT(ACTION_PRINT), NINT(0)), @"-p",
|
NARRAY(NINT(ACTION_PRINT), NINT(0)), @"-p",
|
||||||
NARRAY(NINT(ACTION_LINT), NINT(0)), @"-lint",
|
NARRAY(NINT(ACTION_LINT), NINT(0)), @"-lint",
|
||||||
NARRAY(NINT(ACTION_CONVERT), NINT(1)), @"-convert",
|
NARRAY(NINT(ACTION_CONVERT), NINT(1)), @"-convert",
|
||||||
NARRAY(NINT(ACTION_INSERT), NINT(3)), @"-insert",
|
NARRAY(NINT(ACTION_INSERT), NINT(3)), @"-insert",
|
||||||
NARRAY(NINT(ACTION_REPLACE), NINT(3)), @"-replace",
|
NARRAY(NINT(ACTION_REPLACE), NINT(3)), @"-replace",
|
||||||
NARRAY(NINT(ACTION_REMOVE), NINT(1)), @"-remove",
|
NARRAY(NINT(ACTION_REMOVE), NINT(1)), @"-remove",
|
||||||
NARRAY(NINT(ACTION_EXTRACT), NINT(2)), @"-extract",
|
NARRAY(NINT(ACTION_EXTRACT), NINT(2)), @"-extract",
|
||||||
nil];
|
nil];
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue