Skip to content
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

Merged
merged 6 commits into from Oct 6, 2019
Merged

Update SwiftCLI #667

merged 6 commits into from Oct 6, 2019

Conversation

giginet
Copy link
Collaborator

@giginet giginet commented Sep 30, 2019

Motivation

In the current version of SwiftCLI raises a lot of warnings.

/Users/giginet/.ghq/github.com/yonaskolb/XcodeGen/.build/checkouts/SwiftCLI/Sources/SwiftCLI/Validation.swift:40:5: warning: 'public' modifier is redundant for static method declared in a public extension
    public static func allowing(_ values: T..., message: String? = nil) -> Validation {
    ^~~~~~~

/Users/giginet/.ghq/github.com/yonaskolb/XcodeGen/.build/checkouts/SwiftCLI/Sources/SwiftCLI/Validation.swift:45:5: warning: 'public' modifier is redundant for static method declared in a public extension
    public static func rejecting(_ values: T..., message: String? = nil) -> Validation {
    ^~~~~~~

/Users/giginet/.ghq/github.com/yonaskolb/XcodeGen/.build/checkouts/SwiftCLI/Sources/SwiftCLI/Validation.swift:54:5: warning: 'public' modifier is redundant for static method declared in a public extension
    public static func greaterThan(_ value: T, message: String? = nil) -> Validation {
    ^~~~~~~

/Users/giginet/.ghq/github.com/yonaskolb/XcodeGen/.build/checkouts/SwiftCLI/Sources/SwiftCLI/Validation.swift:58:5: warning: 'public' modifier is redundant for static method declared in a public extension
    public static func lessThan(_ value: T, message: String? = nil) -> Validation {
    ^~~~~~~

/Users/giginet/.ghq/github.com/yonaskolb/XcodeGen/.build/checkouts/SwiftCLI/Sources/SwiftCLI/Validation.swift:62:5: warning: 'public' modifier is redundant for static method declared in a public extension
    public static func within(_ range: ClosedRange<T>, message: String? = nil) -> Validation {
    ^~~~~~~

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.

import Foundation
import SwiftCLI

class CommandRouter: Router {
Copy link
Collaborator Author

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 {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

struct

@giginet
Copy link
Collaborator Author

giginet commented Oct 2, 2019

Ready for review ✨

Copy link
Owner

@yonaskolb yonaskolb left a 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)
Copy link
Owner

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

Copy link
Owner

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

Copy link
Collaborator Author

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

Copy link
Collaborator Author

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
Copy link
Owner

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")),
Copy link
Owner

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

Copy link
Collaborator Author

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.

@yonaskolb yonaskolb merged commit 8c2700a into yonaskolb:master Oct 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants