I've started to use ArgumentParser for some command-line programs and like it. What I am wondering about now is whether it would be appropriate to use it to parse commands that are issued from within a program?
ArgumentParser has a tendency to call
exit when bad things happen and I don't want that to happen. I want to retain control and let the user try again. In my slight experimentation so far, I see that
Cmd.parseAsRoot(arguments) throw so I can catch errors and keep going.
Two questions really:
(a) is such a non-command-line usage bending the purpose of ArgumentParser too much? I have read far and wide, and not found any suggestion that others are using it like this. Is there reason I have missed?
(b) errors thrown by
parseAsRoot such as:
CommandError(commandStack: [ArgsParzChex.Cmd], parserError: ArgumentParser.ParserError.noValue( forKey: ArgumentParser.InputKey(rawValue: "outputFile")))
require processing before being exposed to readers; is ArgumentParser's code that does this exposed in the public API?