SwiftArgs v1.0.0 Release Notes

Release Date: 2017-06-09 // almost 7 years ago
  • 📜 CommandParser.parseCommandLine(_:) no longer throws. Instead, you can handle parsing errors in a new CommandParserDelegate function, parserError(_:). This makes it easy to run parsing in a background thread and for better separation of concerns.

    class Delegate : CommandParserDelegate { /\*\* Called if there was a problem.\*/func parserError(error : CommandParserError) { //Handle error } /\*\* Called if there were no command-line arguments supplied to your program.\*/func commandNotSupplied() { //Handle commands not supplied } /\*\* Called if a command was parsed successfully.\*/func receivedCommand(command : Command) { //Handle successfully-parsed commands } }let delegate = Delegate()let commandParser = CommandParser() commandParser.parseCommandLine(delegate: delegate)