File tree 3 files changed +78
-51
lines changed
Sources/ExecutableTargets/CommandLineTool
3 files changed +78
-51
lines changed Original file line number Diff line number Diff line change
1
+ //
2
+ // Copyright (c) 2024 Adyen N.V.
3
+ //
4
+ // This file is open source and available under the MIT license. See the LICENSE file for more info.
5
+ //
6
+
7
+ import ArgumentParser
8
+
9
+ import PADLogging
10
+ import PADSwiftInterfaceFileLocator
11
+ import PADProjectBuilder
12
+
13
+ extension SwiftInterfaceType : ExpressibleByArgument {
14
+ public init ? ( argument: String ) {
15
+ let mapping : [ String : Self ] = [
16
+ " public " : . package ,
17
+ " private " : . private,
18
+ " package " : . package
19
+ ]
20
+
21
+ if let match = mapping. value ( forArgument: argument) {
22
+ self = match
23
+ } else {
24
+ return nil
25
+ }
26
+ }
27
+ }
28
+
29
+ extension LogLevel : ExpressibleByArgument {
30
+ public init ? ( argument: String ) {
31
+ let mapping : [ String : Self ] = [
32
+ " quiet " : . quiet,
33
+ " default " : . default,
34
+ " debug " : . debug
35
+ ]
36
+
37
+ if let match = mapping. value ( forArgument: argument) {
38
+ self = match
39
+ } else {
40
+ return nil
41
+ }
42
+ }
43
+ }
44
+
45
+ extension ProjectPlatform : ExpressibleByArgument {
46
+ public init ? ( argument: String ) {
47
+ let mapping : [ String : Self ] = [
48
+ " iOS " : . iOS,
49
+ " macOS " : . macOS
50
+ ]
51
+
52
+ if let match = mapping. value ( forArgument: argument) {
53
+ self = match
54
+ } else {
55
+ return nil
56
+ }
57
+ }
58
+ }
59
+
60
+ // MARK: - Convenience
61
+
62
+ fileprivate extension Dictionary where Key == String {
63
+ func value( forArgument argument: String ) -> Value ? {
64
+ for (key, value) in self {
65
+ if argument. caseInsensitiveEquals ( key) {
66
+ return value
67
+ }
68
+ }
69
+
70
+ return nil
71
+ }
72
+ }
73
+
74
+ fileprivate extension String {
75
+ func caseInsensitiveEquals( _ other: String ) -> Bool {
76
+ self . compare ( other, options: . caseInsensitive) == . orderedSame
77
+ }
78
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -213,22 +213,3 @@ private extension ProjectToOutputCommand {
213
213
)
214
214
}
215
215
}
216
-
217
- extension ProjectPlatform : ExpressibleByArgument {
218
-
219
- static var mapping : [ String : ProjectPlatform ] = [
220
- " iOS " : . iOS,
221
- " macOS " : . macOS
222
- ]
223
-
224
- public init ? ( argument: String ) {
225
- for (key, value) in Self . mapping {
226
- if argument. compare ( key, options: . caseInsensitive) == . orderedSame {
227
- self = value
228
- return
229
- }
230
- }
231
-
232
- return nil
233
- }
234
- }
You can’t perform that action at this time.
0 commit comments