New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update SwiftCLI #667
Update SwiftCLI #667
Conversation
import Foundation | ||
import SwiftCLI | ||
|
||
class CommandRouter: Router { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Router
seems to be removed from latest SwiftCLI. Using ArgumentListManipulator
instead.
@@ -3,6 +3,21 @@ import ProjectSpec | |||
import SwiftCLI | |||
|
|||
public class XcodeGenCLI { | |||
private class Manipulator: ArgumentListManipulator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
struct
Ready for review ✨ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @giginet. Can you add a changelog entry into an Internal
section as well
cli.parser = Parser(router: CommandRouter(defaultCommand: generateCommand)) | ||
let manipulator = Manipulator(commandName: generateCommand.name) | ||
cli.argumentListManipulators.insert(manipulator, at: 0) | ||
cli.parser.routeBehavior = .searchWithFallback(generateCommand) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this new routeBehaviour replace the need for the Manipulator
? The purpose of that was to make generate
the default command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it works fine with just the routeBehaviour
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried getting rid of any custom manipulators. However, behavior is changed. So it is needed.
$ swift run xcodegen # works fine
$ swift run xcodegen generate # behaviors are changed.
Usage: xcodegen [options]
Generate an Xcode project from a spec
Options:
--cache-path <value> Where the cache file will be loaded from and save to. Defaults to ~/.xcodegen/cache/{SPEC_PATH_HASH}
-c, --use-cache Use a cache for the xcodegen spec. This will prevent unnecessarily generating the project if nothing has changed
-h, --help Show help information
-p, --project <value> The path to the directory where the project should be generated. Defaults to the directory the spec is in. The filename is defined in the project spec
-q, --quiet Suppress all informational and success output
-s, --spec <value> The path to the project spec file. Defaults to project.yml
Error: command requires exactly 0 arguments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried again, it will works as you said. Manipulators are not needed.
@@ -3,6 +3,17 @@ import ProjectSpec | |||
import SwiftCLI | |||
|
|||
public class XcodeGenCLI { | |||
private struct Manipulator: ArgumentListManipulator { | |||
let commandName: String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we name this defaultCommand
Package.swift
Outdated
@@ -16,7 +16,7 @@ let package = Package( | |||
.package(url: "https://github.com/kylef/Spectre.git", from: "0.9.0"), | |||
.package(url: "https://github.com/onevcat/Rainbow.git", from: "3.0.0"), | |||
.package(url: "https://github.com/tuist/xcodeproj.git", .exact("7.1.0")), | |||
.package(url: "https://github.com/jakeheis/SwiftCLI.git", .exact("5.2.2")), | |||
.package(url: "https://github.com/jakeheis/SwiftCLI.git", .exact("5.3.2")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can make this from
, incase other packages using XcodeGen also use SwiftCLI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to use upToNextMinor(from:)
than from
. Because SwiftCLI brought breaking change when minor versions are updated.
Motivation
In the current version of SwiftCLI raises a lot of warnings.
Description
Use latest SwiftCUI(5.3.2) to avoid warning.
SwiftCLI 5.3 took breaking changes.
jakeheis/SwiftCLI@5.2.2...5.3.2
So I use newer API for the frontend.