@@ -37,21 +37,38 @@ struct GeneratorCommand: CommandPlugin {
37
37
return " generated/EntityInfo- \( targetName) .generated.swift "
38
38
}
39
39
40
+ // Removes the `--target` option and its value from the arguments array
41
+ // This is needed because the `--target` option is not recognized by the Sourcery executable
42
+ private func removeTargetNameFromArgs( _ args: [ String ] ) -> [ String ] {
43
+ var filteredArgs = args
44
+ if let targetIndex = filteredArgs. firstIndex ( of: " --target " ) {
45
+ // Remove --target and the following value (target name)
46
+ filteredArgs. remove ( at: targetIndex)
47
+ if targetIndex < filteredArgs. count {
48
+ filteredArgs. remove ( at: targetIndex)
49
+ }
50
+ }
51
+ return filteredArgs
52
+ }
53
+
40
54
private func runGenerator(
41
- generator: PluginContext . Tool , targetPath: Path , codeFilePath: String , modelFilePath: String
55
+ generator: PluginContext . Tool , targetPath: Path , codeFilePath: String , modelFilePath: String ,
56
+ args: [ String ] = [ ]
42
57
) {
43
58
let modelFileTargetPath = targetPath. appending ( modelFilePath) . string
44
59
let codeFileTargetPath = targetPath. appending ( codeFilePath) . string
45
60
61
+ // The generator does not support the --target argument and would error, remove it
62
+ let filteredArgs = removeTargetNameFromArgs ( args)
63
+
46
64
// Specify --sources for Xcode project setup as well, Sourcery does not seem able to detect Xcode project
47
- let args : [ String ] = [
48
- " --sources " , targetPath. string,
49
- " --model-json " , modelFileTargetPath,
50
- " --output " , codeFileTargetPath,
51
- " --disableCache " ,
52
- " --verbose " ,
53
- " --no-statistics " ,
54
- ]
65
+ let args : [ String ] =
66
+ [
67
+ " --sources " , targetPath. string,
68
+ " --model-json " , modelFileTargetPath,
69
+ " --output " , codeFileTargetPath,
70
+ " --disableCache " ,
71
+ ] + filteredArgs
55
72
56
73
runGenerator ( generator: generator, args: args)
57
74
}
@@ -149,7 +166,7 @@ struct GeneratorCommand: CommandPlugin {
149
166
let modelFilePath = buildModelJsonFilePath ( targetName: target. name)
150
167
runGenerator (
151
168
generator: tool, targetPath: targetPath, codeFilePath: codeFilePath,
152
- modelFilePath: modelFilePath)
169
+ modelFilePath: modelFilePath, args : arguments )
153
170
}
154
171
}
155
172
}
@@ -186,7 +203,7 @@ struct GeneratorCommand: CommandPlugin {
186
203
// the generator and let it find source files.
187
204
runGenerator (
188
205
generator: tool, targetPath: targetPath, codeFilePath: codeFilePath,
189
- modelFilePath: modelFilePath)
206
+ modelFilePath: modelFilePath, args : arguments )
190
207
191
208
// TODO Add the generated files to the Xcode project
192
209
Diagnostics . remark (
0 commit comments