Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cuckoofile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ exclude = [
]
# regex = ""
output = "Tests/Swift/Generated/GeneratedMocks.swift"
# output = "Tests/Swift/Generated/"

[modules.Cuckoo.options]
glob = true
keepDocumentation = false
filePrefix = [
"// swiftlint:disable all",
]
fileSuffix = [
"// swiftlint:enable all",
]

[modules.Cuckoo.xcodeproj]
path = "Generator"
Expand Down
4 changes: 2 additions & 2 deletions Generator/Sources/CLI/GenerateCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ struct GenerateCommand: AsyncParsableCommand {
?? originalFileName
let outputFile = TextFile(path: absoluteOutputPath + "\(fileNameWithoutExtension).swift")
do {
try outputFile.write(generatedFile.contents)
try outputFile.write(module.options.filePrefix + generatedFile.contents + module.options.fileSuffix)
} catch {
log(.error, message: "Failed to write to file '\(outputFile)':", error)
}
}
} else {
let outputFile = TextFile(path: absoluteOutputPath)
do {
try outputFile.write(generatedFiles.map(\.contents).joined(separator: "\n\n"))
try outputFile.write(module.options.filePrefix + generatedFiles.map(\.contents).joined(separator: "\n\n") + module.options.filePrefix)
} catch {
log(.error, message: "Failed to write to file '\(outputFile)':", error)
}
Expand Down
8 changes: 7 additions & 1 deletion Generator/Sources/CLI/Module.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ final class Module {
keepDocumentation: dto.options?.keepDocumentation ?? true,
enableInheritance: dto.options?.enableInheritance ?? true,
protocolsOnly: dto.options?.protocolsOnly ?? false,
omitHeaders: dto.options?.omitHeaders ?? false
omitHeaders: dto.options?.omitHeaders ?? false,
filePrefix: dto.options?.filePrefix?.joined(separator: "\n").appending("\n") ?? "",
fileSuffix: dto.options?.fileSuffix?.joined(separator: "\n").appending("\n") ?? ""
)

if let xcodeproj = dto.xcodeproj {
Expand Down Expand Up @@ -64,6 +66,8 @@ final class Module {
let enableInheritance: Bool
let protocolsOnly: Bool
let omitHeaders: Bool
let filePrefix: String
let fileSuffix: String
}

struct Xcodeproj {
Expand Down Expand Up @@ -107,6 +111,8 @@ extension Module {
let enableInheritance: Bool?
let protocolsOnly: Bool?
let omitHeaders: Bool?
let filePrefix: [String]?
let fileSuffix: [String]?
}

struct Xcodeproj: Decodable {
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ sources = [
"Tests/Swift/Source/*.swift",
]
exclude = ["ExcludedTestClass"]

# Optionally you can use a regular expression to filter only specific classes/protocols.
# regex = ""

Expand All @@ -137,6 +138,15 @@ keepDocumentation = false
# protocolsOnly = true
# omitHeaders = true

# You can add prefix lines to the beginning of each file written, and suffix lines to the end
# For example, this config can be used to turn swiftlint off at the start and back on at the end
prefixLines = [
"// swiftlint:disable all",
]
SuffixLines = [
"// swiftlint:enable all",
]

# If specified, Cuckoo can also get sources for the module from an Xcode target.
[modules.MyProject.xcodeproj]
# Path to folder with .xcodeproj, omit this if it's at the same level as Cuckoofile.
Expand Down