0001 public enum GroupError: ErrorType, Equatable, CustomStringConvertible { 0002 /// No-subcommand was found with the given name 0003 case UnknownCommand
Group.swift:25 public func == (lhs: GroupError, rhs: GroupError) -> Bool {Group.swift:25 public func == (lhs: GroupError, rhs: GroupError) -> Bool {Group.swift:76 throw GroupError.UnknownCommand("\(name) \(childName)")Group.swift:79 throw GroupError.NoCommand("\(name) \(path)", group)Group.swift:82 throw GroupError.NoCommand(name, group)Group.swift:89 throw GroupError.UnknownCommand(name)Group.swift:92 throw GroupError.NoCommand(nil, self)(String) 0004 0005 /// No command was given 0006 /// :param: The current path to the command (i.e, all the group names) 0007 /// :param: The group raising the error 0008 case NoCommand
Group.swift:12 case .UnknownCommand(let name):Group.swift:27 case let (.UnknownCommand(lhsCommand), .UnknownCommand(rhsCommand)):Group.swift:27 case let (.UnknownCommand(lhsCommand), .UnknownCommand(rhsCommand)):Group.swift:75 } catch GroupError.UnknownCommand(let childName) {Group.swift:76 throw GroupError.UnknownCommand("\(name) \(childName)")Group.swift:89 throw GroupError.UnknownCommand(name)(String?, Group) 0009 0010 public var description:String { 0011 switch self { 0012 case .UnknownCommand(let name): 0013 return "Unknown command: `\(name)`" 0014 case .NoCommand(let path, let group): 0015 let available = group.commands.map { $0.name }.sort().joinWithSeparator(", ") 0016 if let path = path { 0017 return "Usage: \(path) COMMAND\n\nCommands: \(available)" 0018 } else { 0019 return "Commands: \(available)" 0020 } 0021 } 0022 } 0023 } 0024 0025 public func == (lhs: GroupError, rhs: GroupError) -> Bool { 0026 switch (lhs, rhs) { 0027 case let (.UnknownCommand(lhsCommand), .UnknownCommand(rhsCommand)): 0028 return lhsCommand == rhsCommand 0029 case let (.NoCommand(lhsPath, lhsGroup), .NoCommand(rhsPath, rhsGroup)): 0030 return lhsPath == rhsPath && lhsGroup === rhsGroup 0031 default: 0032 return false 0033 } 0034 } 0035 0036 /// Represents a group of commands 0037 public class Group
CommandRunner.swift:29 } catch GroupError.NoCommand(let path, let group) {Group.swift:14 case .NoCommand(let path, let group):Group.swift:29 case let (.NoCommand(lhsPath, lhsGroup), .NoCommand(rhsPath, rhsGroup)):Group.swift:29 case let (.NoCommand(lhsPath, lhsGroup), .NoCommand(rhsPath, rhsGroup)):Group.swift:77 } catch GroupError.NoCommand(let path, let group) {Group.swift:79 throw GroupError.NoCommand("\(name) \(path)", group)Group.swift:82 throw GroupError.NoCommand(name, group)Group.swift:92 throw GroupError.NoCommand(nil, self): CommandType { 0038 struct SubCommand
ArgumentDescription.swift:229 let group:Group?ArgumentDescription.swift:232 init(_ descriptors:[BoxedArgumentDescriptor], command:String? = nil, group:Group? = nil) {Commands.swift:587 extension Group {Group.swift:8 case NoCommand(String?, Group)Group.swift:97 extension Group {Group.swift:98 public convenience init(@noescape closure: Group -> ()) {Group.swift:104 public func group(name: String, _ description: String? = nil, @noescape closure: Group -> ()) {Group.swift:105 addCommand(name, description, Group(closure: closure)){ 0039 let name
Group.swift:50 var commands = [SubCommand]()Group.swift:60 commands.append(SubCommand(name: name, description: nil, command: command))Group.swift:65 commands.append(SubCommand(name: name, description: description, command: command)): String 0040 let description
ArgumentDescription.swift:266 output.append(" + \(command.name) - \(description)")ArgumentDescription.swift:268 output.append(" + \(command.name)")Group.swift:15 let available = group.commands.map { $0.name }.sort().joinWithSeparator(", ")Group.swift:44 self.name = nameGroup.swift:71 let command = commands.filter { $0.name == name }.first: String? 0041 let command
ArgumentDescription.swift:265 if let description = command.description {Group.swift:45 self.description = description: CommandType 0042 0043 init
Group.swift:46 self.command = commandGroup.swift:74 try command.command.run(parser)(name: String, description: String?, command: CommandType) { 0044 self.name = name 0045 self.description = description 0046 self.command = command 0047 } 0048 } 0049 0050 var commands
Group.swift:60 commands.append(SubCommand(name: name, description: nil, command: command))Group.swift:65 commands.append(SubCommand(name: name, description: description, command: command))= [SubCommand]() 0051 0052 // When set, allows you to override the default unknown command behaviour 0053 public var unknownCommand
ArgumentDescription.swift:264 for command in group.commands {Group.swift:15 let available = group.commands.map { $0.name }.sort().joinWithSeparator(", ")Group.swift:60 commands.append(SubCommand(name: name, description: nil, command: command))Group.swift:65 commands.append(SubCommand(name: name, description: description, command: command))Group.swift:71 let command = commands.filter { $0.name == name }.first: ((name: String, parser: ArgumentParser) throws -> ())? 0054 0055 /// Create a new group 0056 public init
Group.swift:86 } else if let unknownCommand = unknownCommand {() {} 0057 0058 /// Add a named sub-command to the group 0059 public func addCommand(name: String, _ command: CommandType) { 0060 commands.append(SubCommand(name: name, description: nil, command: command)) 0061 } 0062 0063 /// Add a named sub-command to the group with a description 0064 public func addCommand
Group.swift:99 self.init()(name: String, _ description: String?, _ command: CommandType) { 0065 commands.append(SubCommand(name: name, description: description, command: command)) 0066 } 0067 0068 /// Run the group command 0069 public func run(parser: ArgumentParser) throws { 0070 if let name = parser.shift() { 0071 let command = commands.filter { $0.name == name }.first 0072 if let command = command { 0073 do { 0074 try command.command.run(parser) 0075 } catch GroupError.UnknownCommand(let childName) { 0076 throw GroupError.UnknownCommand("\(name) \(childName)") 0077 } catch GroupError.NoCommand(let path, let group) { 0078 if let path = path { 0079 throw GroupError.NoCommand("\(name) \(path)", group) 0080 } 0081 0082 throw GroupError.NoCommand(name, group) 0083 } catch let error as Help { 0084 throw error.reraise(name) 0085 } 0086 } else if let unknownCommand = unknownCommand { 0087 try unknownCommand(name: name, parser: parser) 0088 } else { 0089 throw GroupError.UnknownCommand(name) 0090 } 0091 } else { 0092 throw GroupError.NoCommand(nil, self) 0093 } 0094 } 0095 } 0096 0097 extension Group { 0098 public convenience init
Commands.swift:592 addCommand(name, description, Commander.command(closure))Commands.swift:597 addCommand(name, description, Commander.command(closure))Commands.swift:602 addCommand(name, description, Commander.command(closure))Commands.swift:607 addCommand(name, description, Commander.command(closure))Commands.swift:612 addCommand(name, description, Commander.command(closure))Commands.swift:617 addCommand(name, description, Commander.command(closure))Commands.swift:622 addCommand(name, description, Commander.command(closure))Commands.swift:627 addCommand(name, description, Commander.command(closure))Commands.swift:632 addCommand(name, description, Commander.command(closure))Commands.swift:637 addCommand(name, description, Commander.command(closure))Commands.swift:642 addCommand(name, description, Commander.command(closure))Commands.swift:647 addCommand(name, description, Commander.command(closure))Commands.swift:652 addCommand(name, description, Commander.command(closure))Commands.swift:657 addCommand(name, description, Commander.command(closure))Commands.swift:662 addCommand(name, description, Commander.command(closure))Commands.swift:670 addCommand(name, description, Commander.command(descriptor, closure: closure))Commands.swift:675 addCommand(name, description, Commander.command(descriptor, descriptor1, closure: closure))Commands.swift:680 addCommand(name, description, Commander.command(descriptor, descriptor1, descriptor2, closure: closure))Commands.swift:685 addCommand(name, description, Commander.command(descriptor, descriptor1, descriptor2, descriptor3, closure: closure))Commands.swift:690 addCommand(name, description, Commander.command(descriptor, descriptor1, descriptor2, descriptor3, descriptor4, closure: closure))Commands.swift:695 addCommand(name, description, Commander.command(descriptor, descriptor1, descriptor2, descriptor3, descriptor4, descriptor5, closure: closure))Commands.swift:700 addCommand(name, description, Commander.command(descriptor, descriptor1, descriptor2, descriptor3, descriptor4, descriptor5, descriptor6, closure: closure))Commands.swift:705 addCommand(name, description, Commander.command(descriptor, descriptor1, descriptor2, descriptor3, descriptor4, descriptor5, descriptor6, descriptor7, closure: closure))Commands.swift:710 addCommand(name, description, Commander.command(descriptor, descriptor1, descriptor2, descriptor3, descriptor4, descriptor5, descriptor6, descriptor7, descriptor8, closure: closure))Commands.swift:715 addCommand(name, description, Commander.command(descriptor, descriptor1, descriptor2, descriptor3, descriptor4, descriptor5, descriptor6, descriptor7, descriptor8, descriptor9, closure: closure))Commands.swift:720 addCommand(name, description, Commander.command(descriptor, descriptor1, descriptor2, descriptor3, descriptor4, descriptor5, descriptor6, descriptor7, descriptor8, descriptor9, descriptor10, closure: closure))Commands.swift:725 addCommand(name, description, Commander.command(descriptor, descriptor1, descriptor2, descriptor3, descriptor4, descriptor5, descriptor6, descriptor7, descriptor8, descriptor9, descriptor10, descriptor11, closure: closure))Commands.swift:730 addCommand(name, description, Commander.command(descriptor, descriptor1, descriptor2, descriptor3, descriptor4, descriptor5, descriptor6, descriptor7, descriptor8, descriptor9, descriptor10, descriptor11, descriptor12, closure: closure))Commands.swift:735 addCommand(name, description, Commander.command(descriptor, descriptor1, descriptor2, descriptor3, descriptor4, descriptor5, descriptor6, descriptor7, descriptor8, descriptor9, descriptor10, descriptor11, descriptor12, descriptor13, closure: closure))Group.swift:105 addCommand(name, description, Group(closure: closure))(@noescape closure: Group -> ()) { 0099 self.init() 0100 closure(self) 0101 } 0102 0103 /// Add a sub-group using a closure 0104 public func group(name: String, _ description: String? = nil, @noescape closure: Group -> ()) { 0105 addCommand(name, description, Group(closure: closure)) 0106 } 0107 } 0108
Group.swift:105 addCommand(name, description, Group(closure: closure))