@@ -39,6 +39,7 @@ extension FileManager: FileChecker {}
39
39
struct LaunchArgs {
40
40
/// Keys associated with the launch args. See `Usage` for descriptions of each flag.
41
41
private enum Key : String , CaseIterable {
42
+ case buildRoot
42
43
case carthageDir
43
44
case customSpecRepos
44
45
case existingVersions
@@ -51,6 +52,9 @@ struct LaunchArgs {
51
52
/// Usage description for the key.
52
53
var usage : String {
53
54
switch self {
55
+ case . buildRoot:
56
+ return " The root directory for build artifacts. If `nil`, a temporary directory will be " +
57
+ " used. "
54
58
case . carthageDir:
55
59
return " The directory pointing to all Carthage JSON manifests. Passing this flag enables " +
56
60
" the Carthage build. "
@@ -79,6 +83,9 @@ struct LaunchArgs {
79
83
/// verify expected version numbers.
80
84
let allSDKsPath : URL ?
81
85
86
+ /// The root directory for build artifacts. If `nil`, a temporary directory will be used.
87
+ let buildRoot : URL ?
88
+
82
89
/// The directory pointing to all Carthage JSON manifests. Passing this flag enables the Carthage
83
90
/// build.
84
91
let carthageDir : URL ?
@@ -105,6 +112,9 @@ struct LaunchArgs {
105
112
/// A flag to update the Pod Repo or not.
106
113
let updatePodRepo : Bool
107
114
115
+ /// The shared instance for processing launch args using default arguments.
116
+ static let shared : LaunchArgs = LaunchArgs ( )
117
+
108
118
/// Initializes with values pulled from the instance of UserDefaults passed in.
109
119
///
110
120
/// - Parameters:
@@ -219,6 +229,20 @@ struct LaunchArgs {
219
229
carthageDir = nil
220
230
}
221
231
232
+ // Parse the Carthage directory key.
233
+ if let buildRoot = defaults. string ( forKey: Key . buildRoot. rawValue) {
234
+ let url = URL ( fileURLWithPath: buildRoot)
235
+ guard fileChecker. directoryExists ( at: url) else {
236
+ LaunchArgs . exitWithUsageAndLog ( " Could not parse \( Key . buildRoot) key: value " +
237
+ " passed in is not a file URL or the directory does not exist. Value: \( buildRoot) " )
238
+ }
239
+
240
+ self . buildRoot = url. standardizedFileURL
241
+ } else {
242
+ // No argument was passed in.
243
+ buildRoot = nil
244
+ }
245
+
222
246
updatePodRepo = defaults. bool ( forKey: Key . updatePodRepo. rawValue)
223
247
}
224
248
0 commit comments