mirror of
https://github.com/yonaskolb/XcodeGen.git
synced 2024-08-17 00:30:29 +03:00
update migrate command
This commit is contained in:
parent
4691c4e577
commit
da7eabf148
@ -8,25 +8,21 @@ import Yams
|
|||||||
|
|
||||||
class MigrateCommand: Command {
|
class MigrateCommand: Command {
|
||||||
let name: String = "migrate"
|
let name: String = "migrate"
|
||||||
|
let shortDescription: String = "Migrates an Xcode project to an XcodeGen project spec"
|
||||||
|
|
||||||
let projectFile = Key<Path>("-p", "--project", description: "The path to the project file")
|
@Param
|
||||||
|
var projectPath: Path
|
||||||
|
|
||||||
let spec = Key<Path>(
|
@Key("-s", "--spec", description: "The path to the generated project spec. Defaults to project.yml in the same directory as the project")
|
||||||
"-s",
|
var spec: Path?
|
||||||
"--spec",
|
|
||||||
description: "The path to the project spec file should be generated. Defaults to project.yml"
|
|
||||||
)
|
|
||||||
|
|
||||||
func execute() throws {
|
func execute() throws {
|
||||||
guard let file = projectFile.value else {
|
let xcodeProj = try XcodeProj(path: projectPath)
|
||||||
return
|
let project = try generateSpec(xcodeProj: xcodeProj, projectDirectory: projectPath.parent())
|
||||||
}
|
|
||||||
let xcodeProj = try XcodeProj(path: file)
|
|
||||||
let project = try generateSpec(xcodeProj: xcodeProj, projectDirectory: file.parent())
|
|
||||||
let projectDict = project.toJSONDictionary().removeEmpty()
|
let projectDict = project.toJSONDictionary().removeEmpty()
|
||||||
let encodedYAML = try Yams.dump(object: projectDict)
|
let encodedYAML = try Yams.dump(object: projectDict)
|
||||||
let defaultOutPath = file.parent() + "project.yml"
|
let defaultOutPath = projectPath.parent() + "project.yml"
|
||||||
let outPath = spec.value ?? defaultOutPath
|
let outPath = spec ?? defaultOutPath
|
||||||
try encodedYAML.write(toFile: outPath.string, atomically: true, encoding: .utf8)
|
try encodedYAML.write(toFile: outPath.string, atomically: true, encoding: .utf8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user