-
Notifications
You must be signed in to change notification settings - Fork 808
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Can we name this |
||
|
||
func manipulate(arguments: ArgumentList) { | ||
if !arguments.hasNext() || arguments.nextIsOption() { | ||
arguments.manipulate { existing in | ||
return [commandName] + existing | ||
} | ||
} | ||
} | ||
} | ||
|
||
let cli: CLI | ||
|
||
|
@@ -15,7 +26,9 @@ public class XcodeGenCLI { | |
description: "Generates Xcode projects", | ||
commands: [generateCommand] | ||
) | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Does this new routeBehaviour replace the need for the There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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. |
||
} | ||
|
||
public func execute(arguments: [String]? = nil) { | ||
|
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 SwiftCLIThere 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:)
thanfrom
. Because SwiftCLI brought breaking change when minor versions are updated.