@@ -8,15 +8,15 @@ public protocol ArgumentDescriptor {
88 associatedtype ValueType
99
1010 /// The arguments name
11- var name : String { get }
11+ var name : String { get }
1212
1313 /// The arguments description
14- var description : String ? { get }
14+ var description : String ? { get }
1515
16- var type : ArgumentType { get }
16+ var type : ArgumentType { get }
1717
1818 /// Parse the argument
19- func parse( _ parser: ArgumentParser ) throws -> ValueType
19+ func parse( _ parser: ArgumentParser ) throws -> ValueType
2020}
2121
2222
@@ -27,23 +27,23 @@ extension ArgumentConvertible {
2727}
2828
2929
30- open class VariadicArgument < T : ArgumentConvertible > : ArgumentDescriptor {
30+ public class VariadicArgument < T : ArgumentConvertible > : ArgumentDescriptor {
3131 public typealias ValueType = [ T ]
3232 public typealias Validator = ( ValueType ) throws -> ValueType
3333
34- open let name : String
35- open let description : String ?
36- open let validator : Validator ?
34+ public let name : String
35+ public let description : String ?
36+ public let validator : Validator ?
3737
38- open var type : ArgumentType { return . argument }
38+ public var type : ArgumentType { return . argument }
3939
4040 public init ( _ name: String , description: String ? = nil , validator: Validator ? = nil ) {
4141 self . name = name
4242 self . description = description
4343 self . validator = validator
4444 }
4545
46- open func parse( _ parser: ArgumentParser ) throws -> ValueType {
46+ public func parse( _ parser: ArgumentParser ) throws -> ValueType {
4747 let value = try Array < T > ( parser: parser)
4848
4949 if let validator = validator {
@@ -58,23 +58,23 @@ open class VariadicArgument<T : ArgumentConvertible> : ArgumentDescriptor {
5858typealias VaradicArgument < T : ArgumentConvertible > = VariadicArgument < T >
5959
6060
61- open class Argument < T : ArgumentConvertible > : ArgumentDescriptor {
61+ public class Argument < T : ArgumentConvertible > : ArgumentDescriptor {
6262 public typealias ValueType = T
6363 public typealias Validator = ( ValueType ) throws -> ValueType
6464
65- open let name : String
66- open let description : String ?
67- open let validator : Validator ?
65+ public let name : String
66+ public let description : String ?
67+ public let validator : Validator ?
6868
69- open var type : ArgumentType { return . argument }
69+ public var type : ArgumentType { return . argument }
7070
71- public init ( _ name: String , description: String ? = nil , validator: Validator ? = nil ) {
71+ public init ( _ name: String , description: String ? = nil , validator: Validator ? = nil ) {
7272 self . name = name
7373 self . description = description
7474 self . validator = validator
7575 }
7676
77- open func parse( _ parser: ArgumentParser ) throws -> ValueType {
77+ public func parse( _ parser: ArgumentParser ) throws -> ValueType {
7878 let value : T
7979
8080 do {
@@ -94,26 +94,26 @@ open class Argument<T : ArgumentConvertible> : ArgumentDescriptor {
9494}
9595
9696
97- open class Option < T : ArgumentConvertible > : ArgumentDescriptor {
97+ public class Option < T : ArgumentConvertible > : ArgumentDescriptor {
9898 public typealias ValueType = T
9999 public typealias Validator = ( ValueType ) throws -> ValueType
100100
101- open let name : String
102- open let flag : Character ?
103- open let description : String ?
104- open let `default` : ValueType
105- open var type : ArgumentType { return . option }
106- open let validator : Validator ?
101+ public let name : String
102+ public let flag : Character ?
103+ public let description : String ?
104+ public let `default` : ValueType
105+ public var type : ArgumentType { return . option }
106+ public let validator : Validator ?
107107
108- public init ( _ name: String , _ default: ValueType , flag: Character ? = nil , description: String ? = nil , validator: Validator ? = nil ) {
108+ public init ( _ name: String , _ default: ValueType , flag: Character ? = nil , description: String ? = nil , validator: Validator ? = nil ) {
109109 self . name = name
110110 self . flag = flag
111111 self . description = description
112112 self . `default` = `default`
113113 self . validator = validator
114114 }
115115
116- open func parse( _ parser: ArgumentParser ) throws -> ValueType {
116+ public func parse( _ parser: ArgumentParser ) throws -> ValueType {
117117 if let value = try parser. shiftValueForOption ( name) {
118118 let value = try T ( string: value)
119119
@@ -141,44 +141,44 @@ open class Option<T : ArgumentConvertible> : ArgumentDescriptor {
141141}
142142
143143
144- open class Options < T : ArgumentConvertible > : ArgumentDescriptor {
144+ public class Options < T : ArgumentConvertible > : ArgumentDescriptor {
145145 public typealias ValueType = [ T ]
146146
147- open let name : String
148- open let description : String ?
149- open let count : Int
150- open let `default` : ValueType
151- open var type : ArgumentType { return . option }
147+ public let name : String
148+ public let description : String ?
149+ public let count : Int
150+ public let `default` : ValueType
151+ public var type : ArgumentType { return . option }
152152
153- public init ( _ name: String , _ default: ValueType , count: Int , description: String ? = nil ) {
153+ public init ( _ name: String , _ default: ValueType , count: Int , description: String ? = nil ) {
154154 self . name = name
155155 self . `default` = `default`
156156 self . count = count
157157 self . description = description
158158 }
159159
160- open func parse( _ parser: ArgumentParser ) throws -> ValueType {
160+ public func parse( _ parser: ArgumentParser ) throws -> ValueType {
161161 let values = try parser. shiftValuesForOption ( name, count: count)
162162 return try values? . map { try T ( string: $0) } ?? `default`
163163 }
164164}
165165
166166
167- open class VariadicOption < T : ArgumentConvertible > : ArgumentDescriptor {
167+ public class VariadicOption < T : ArgumentConvertible > : ArgumentDescriptor {
168168 public typealias ValueType = [ T ]
169169
170- open let name : String
171- open let description : String ?
172- open let `default` : ValueType
173- open var type : ArgumentType { return . option }
170+ public let name : String
171+ public let description : String ?
172+ public let `default` : ValueType
173+ public var type : ArgumentType { return . option }
174174
175- public init ( _ name: String , _ default: ValueType = [ ] , description: String ? = nil ) {
175+ public init ( _ name: String , _ default: ValueType = [ ] , description: String ? = nil ) {
176176 self . name = name
177177 self . `default` = `default`
178178 self . description = description
179179 }
180180
181- open func parse( _ parser: ArgumentParser ) throws -> ValueType {
181+ public func parse( _ parser: ArgumentParser ) throws -> ValueType {
182182 var values : ValueType ? = nil
183183
184184 while let shifted = try parser. shiftValueForOption ( name) {
@@ -195,18 +195,18 @@ open class VariadicOption<T : ArgumentConvertible> : ArgumentDescriptor {
195195}
196196
197197
198- open class Flag : ArgumentDescriptor {
198+ public class Flag : ArgumentDescriptor {
199199 public typealias ValueType = Bool
200200
201- open let name : String
202- open let flag : Character ?
203- open let disabledName : String
204- open let disabledFlag : Character ?
205- open let description : String ?
206- open let `default` : ValueType
207- open var type : ArgumentType { return . option }
201+ public let name : String
202+ public let flag : Character ?
203+ public let disabledName : String
204+ public let disabledFlag : Character ?
205+ public let description : String ?
206+ public let `default` : ValueType
207+ public var type : ArgumentType { return . option }
208208
209- public init ( _ name: String , flag: Character ? = nil , disabledName: String ? = nil , disabledFlag: Character ? = nil , description: String ? = nil , default: Bool = false ) {
209+ public init ( _ name: String , flag: Character ? = nil , disabledName: String ? = nil , disabledFlag: Character ? = nil , description: String ? = nil , default: Bool = false ) {
210210 self . name = name
211211 self . disabledName = disabledName ?? " no- \( name) "
212212 self . flag = flag
@@ -215,7 +215,7 @@ open class Flag : ArgumentDescriptor {
215215 self . `default` = `default`
216216 }
217217
218- open func parse( _ parser: ArgumentParser ) throws -> ValueType {
218+ public func parse( _ parser: ArgumentParser ) throws -> ValueType {
219219 if parser. hasOption ( disabledName) {
220220 return false
221221 }
@@ -241,12 +241,12 @@ open class Flag : ArgumentDescriptor {
241241
242242
243243class BoxedArgumentDescriptor {
244- let name : String
245- let description : String ?
246- let `default` : String ?
247- let type : ArgumentType
244+ let name : String
245+ let description : String ?
246+ let `default` : String ?
247+ let type : ArgumentType
248248
249- init < T : ArgumentDescriptor > ( value: T ) {
249+ init < T : ArgumentDescriptor > ( value: T ) {
250250 name = value. name
251251 description = value. description
252252 type = value. type
@@ -281,17 +281,17 @@ class UsageError : Error, ANSIConvertible, CustomStringConvertible {
281281
282282
283283class Help : Error , ANSIConvertible , CustomStringConvertible {
284- let command : String ?
285- let group : Group ?
286- let descriptors : [ BoxedArgumentDescriptor ]
284+ let command : String ?
285+ let group : Group ?
286+ let descriptors : [ BoxedArgumentDescriptor ]
287287
288- init ( _ descriptors: [ BoxedArgumentDescriptor ] , command: String ? = nil , group: Group ? = nil ) {
288+ init ( _ descriptors: [ BoxedArgumentDescriptor ] , command: String ? = nil , group: Group ? = nil ) {
289289 self . command = command
290290 self . group = group
291291 self . descriptors = descriptors
292292 }
293293
294- func reraise( _ command: String ? = nil ) -> Help {
294+ func reraise( _ command: String ? = nil ) -> Help {
295295 if let oldCommand = self . command, let newCommand = command {
296296 return Help ( descriptors, command: " \( newCommand) \( oldCommand) " )
297297 }
0 commit comments