@@ -39,6 +39,7 @@ extension FileManager: FileChecker {}
3939struct LaunchArgs {
4040 /// Keys associated with the launch args. See `Usage` for descriptions of each flag.
4141 private enum Key : String , CaseIterable {
42+ case buildRoot
4243 case carthageDir
4344 case customSpecRepos
4445 case existingVersions
@@ -51,6 +52,9 @@ struct LaunchArgs {
5152 /// Usage description for the key.
5253 var usage : String {
5354 switch self {
55+ case . buildRoot:
56+ return " The root directory for build artifacts. If `nil`, a temporary directory will be " +
57+ " used. "
5458 case . carthageDir:
5559 return " The directory pointing to all Carthage JSON manifests. Passing this flag enables " +
5660 " the Carthage build. "
@@ -79,6 +83,9 @@ struct LaunchArgs {
7983 /// verify expected version numbers.
8084 let allSDKsPath : URL ?
8185
86+ /// The root directory for build artifacts. If `nil`, a temporary directory will be used.
87+ let buildRoot : URL ?
88+
8289 /// The directory pointing to all Carthage JSON manifests. Passing this flag enables the Carthage
8390 /// build.
8491 let carthageDir : URL ?
@@ -105,6 +112,9 @@ struct LaunchArgs {
105112 /// A flag to update the Pod Repo or not.
106113 let updatePodRepo : Bool
107114
115+ /// The shared instance for processing launch args using default arguments.
116+ static let shared : LaunchArgs = LaunchArgs ( )
117+
108118 /// Initializes with values pulled from the instance of UserDefaults passed in.
109119 ///
110120 /// - Parameters:
@@ -219,6 +229,20 @@ struct LaunchArgs {
219229 carthageDir = nil
220230 }
221231
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+
222246 updatePodRepo = defaults. bool ( forKey: Key . updatePodRepo. rawValue)
223247 }
224248
0 commit comments