Refactor SwiftUI extension generation and generation SwiftUI extension for images
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit

This commit is contained in:
2022-11-03 15:00:27 +01:00
parent 4f7d7e18b1
commit 085f1ffc33
25 changed files with 219 additions and 264 deletions

View File

@ -22,6 +22,7 @@ struct Images: ParsableCommand {
static let toolName = "Images"
static let defaultExtensionName = "UIImage"
static let defaultExtensionNameSUI = "Image"
// MARK: - Command Options
@ -56,8 +57,15 @@ struct Images: ParsableCommand {
staticVar: options.staticMembers,
inputFilename: options.inputFilenameWithoutExt,
extensionName: options.extensionName,
extensionFilePath: options.extensionFilePath)
extensionFilePath: options.extensionFilePath,
isSwiftUI: false)
ImageExtensionGenerator.generateExtensionFile(images: imagesToGenerate,
staticVar: options.staticMembers,
inputFilename: options.inputFilenameWithoutExt,
extensionName: options.extensionNameSwiftUI,
extensionFilePath: options.extensionFilePathSwiftUI,
isSwiftUI: true)
print("[\(Self.toolName)] Images generated")
}
@ -81,6 +89,13 @@ struct Images: ParsableCommand {
// RSVG-Converter
_ = Images.getSvgConverterPath()
// Extension for UIKit and SwiftUI should have different name
guard options.extensionName != options.extensionNameSwiftUI else {
let error = ImagesError.extensionNamesCollision(options.extensionName)
print(error.localizedDescription)
Images.exit(withError: error)
}
// Check if needed to regenerate
guard GeneratorChecker.shouldGenerate(force: options.forceExecution,
inputFilePath: options.inputFile,