From da7eabf148f4d762c238ae42dd7c4d8536769694 Mon Sep 17 00:00:00 2001 From: yonaskolb Date: Wed, 5 Jan 2022 14:08:54 +1100 Subject: [PATCH] update migrate command --- .../XcodeGenCLI/Commands/MigrateCommand.swift | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/Sources/XcodeGenCLI/Commands/MigrateCommand.swift b/Sources/XcodeGenCLI/Commands/MigrateCommand.swift index 2bca097e..91981fe3 100644 --- a/Sources/XcodeGenCLI/Commands/MigrateCommand.swift +++ b/Sources/XcodeGenCLI/Commands/MigrateCommand.swift @@ -8,25 +8,21 @@ import Yams class MigrateCommand: Command { let name: String = "migrate" + let shortDescription: String = "Migrates an Xcode project to an XcodeGen project spec" - let projectFile = Key("-p", "--project", description: "The path to the project file") + @Param + var projectPath: Path - let spec = Key( - "-s", - "--spec", - description: "The path to the project spec file should be generated. Defaults to project.yml" - ) + @Key("-s", "--spec", description: "The path to the generated project spec. Defaults to project.yml in the same directory as the project") + var spec: Path? func execute() throws { - guard let file = projectFile.value else { - return - } - let xcodeProj = try XcodeProj(path: file) - let project = try generateSpec(xcodeProj: xcodeProj, projectDirectory: file.parent()) + let xcodeProj = try XcodeProj(path: projectPath) + let project = try generateSpec(xcodeProj: xcodeProj, projectDirectory: projectPath.parent()) let projectDict = project.toJSONDictionary().removeEmpty() let encodedYAML = try Yams.dump(object: projectDict) - let defaultOutPath = file.parent() + "project.yml" - let outPath = spec.value ?? defaultOutPath + let defaultOutPath = projectPath.parent() + "project.yml" + let outPath = spec ?? defaultOutPath try encodedYAML.write(toFile: outPath.string, atomically: true, encoding: .utf8) } }