-
-
Notifications
You must be signed in to change notification settings - Fork 509
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
Scaffold load #1092
Scaffold load #1092
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1092 +/- ##
=========================================
- Coverage 75.14% 74.5% -0.64%
=========================================
Files 257 262 +5
Lines 11934 9164 -2770
=========================================
- Hits 8968 6828 -2140
+ Misses 2966 2336 -630
Continue to review full report at Codecov.
|
@@ -75,7 +76,10 @@ public final class CommandRegistry { | |||
|
|||
// Normal command | |||
} else { | |||
let parsedArguments = try parse() | |||
guard let parsedArguments = try parse() else { | |||
parser.printUsage(on: stdoutStream) |
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.
This is a good idea. We should do the same with other commands. Not as part of this PR though.
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.
This change is necessitated by this PR. parse()
now returns optional ArgumentParser.Result
if this does not include a command name. I can probably change this implementation back to its original signature.
/// - parser: Default parser | ||
/// - argumets: List of arguments that the user passed to the CLI | ||
/// - Returns: Result of parsing the arguments that the user passed to the CLI. | ||
func parse(with parser: ArgumentParser, arguments: [String]) throws -> ArgumentParser.Result |
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 it need to be part of the protocol?
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.
Yes, otherwise I'd need to rewrite this
fixtures/ios_app_with_templates/Tuist/Templates/custom/Template.swift
Outdated
Show resolved
Hide resolved
Tests/TuistScaffoldIntegrationTests/Utils/TemplatesDirectoryLocatorIntegrationTests.swift
Outdated
Show resolved
Hide resolved
fixtures/ios_app_with_templates/Tuist/Templates/custom/Template.swift
Outdated
Show resolved
Hide resolved
I have addressed your comments, thanks for the review @pepibumur! Next up is generating, will start to work on that now π |
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.
Amazing job @fortmarek π π π
Short description π
Follow-up PR to models - note it will have to be merged first
This PR adds the functionality of defining custom templates in
Tuist/Templates
+ loading the template and parsing it. Generation logic will be added in a follow-up PR.Solution π¦
Custom templates are defined in
Tuist/Templates
inTemplate.swift
. Model has already been defined in a previous PR. When runningtuist scaffold template --name hello
we need to find the template in custom templates directory and then dynamically add its parsed options (--name hello
is not defined inScaffoldCommand
itself)Implementation π©βπ»π¨βπ»
There are several things that needed to be added to make loading of templates work:
ProjectEditor
to be able to edit the templates conveniently in Xcode projectTemplatesLoader
to be able to load the template manifestparse
toCommand
-> this enables everyCommand
to inject additional logic before runningparse
. InScaffoldCommand
we leverage this to add options from template manifest and thus being able to runtuist scaffold template --name hello
where--name hello
is dynamically parsedTemplatesDirectoryLocator
that leverages already implementedRootDirectoryLocator