-
Notifications
You must be signed in to change notification settings - Fork 819
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
68 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import Foundation | ||
import PathKit | ||
import ProjectSpec | ||
import SwiftCLI | ||
import XcodeGenKit | ||
import XcodeProj | ||
import Version | ||
|
||
class CacheCommand: ProjectCommand { | ||
|
||
@Key("--cache-path", description: "Where the cache file will be loaded from and save to. Defaults to ~/.xcodegen/cache/{SPEC_PATH_HASH}") | ||
var cacheFilePath: Path? | ||
|
||
init(version: Version) { | ||
super.init(version: version, | ||
name: "cache", | ||
shortDescription: "Write the project cache") | ||
} | ||
|
||
override func execute(specLoader: SpecLoader, projectSpecPath: Path, project: Project) throws { | ||
|
||
let cacheFilePath = self.cacheFilePath ?? Path("~/.xcodegen/cache/\(projectSpecPath.absolute().string.md5)").absolute() | ||
|
||
var cacheFile: CacheFile? | ||
|
||
// generate cache | ||
do { | ||
cacheFile = try specLoader.generateCacheFile() | ||
} catch { | ||
throw GenerationError.projectSpecParsingError(error) | ||
} | ||
|
||
// write cache | ||
if let cacheFile = cacheFile { | ||
do { | ||
try cacheFilePath.parent().mkpath() | ||
try cacheFilePath.write(cacheFile.string) | ||
success("Wrote cache to \(cacheFilePath)") | ||
} catch { | ||
info("Failed to write cache: \(error.localizedDescription)") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters