Optional generation of extension (R.xx)
Optional generation of Colors/Fonts/Images/Stringium extension Fix swiftlint warning
This commit is contained in:
@ -15,35 +15,51 @@ struct StringiumOptions: ParsableArguments {
|
||||
@Flag(name: [.customShort("f"), .customShort("F")], help: "Should force generation")
|
||||
var forceGeneration = false
|
||||
|
||||
@Argument(help: "Input files where strings are defined.", transform: { $0.replaceTiltWithHomeDirectoryPath() })
|
||||
@Argument(
|
||||
help: "Input files where strings are defined.",
|
||||
transform: { $0.replaceTiltWithHomeDirectoryPath() }
|
||||
)
|
||||
var inputFile: String
|
||||
|
||||
@Option(name: .customLong("output-path"), help: "Path where to strings file.", transform: { $0.replaceTiltWithHomeDirectoryPath() })
|
||||
@Option(
|
||||
name: .customLong("output-path"),
|
||||
help: "Path where to strings file.",
|
||||
transform: { $0.replaceTiltWithHomeDirectoryPath() }
|
||||
)
|
||||
fileprivate var outputPathRaw: String
|
||||
|
||||
@Option(name: .customLong("langs"), help: "Langs to generate.")
|
||||
@Option(
|
||||
name: .customLong("langs"),
|
||||
help: "Langs to generate."
|
||||
)
|
||||
fileprivate var langsRaw: String
|
||||
|
||||
@Option(help: "Default langs.")
|
||||
var defaultLang: String
|
||||
|
||||
@Option(name: .customLong("tags"), help: "Tags to generate.")
|
||||
@Option(
|
||||
name: .customLong("tags"),
|
||||
help: "Tags to generate."
|
||||
)
|
||||
fileprivate var tagsRaw: String = "ios iosonly iosOnly notranslation"
|
||||
|
||||
@Option(help: "Path where to generate the extension.", transform: { $0.replaceTiltWithHomeDirectoryPath() })
|
||||
var extensionOutputPath: String
|
||||
|
||||
@Option(help: "Tell if it will generate static properties or not")
|
||||
@Option(help: "Generate static properties. False by default")
|
||||
var staticMembers: Bool = false
|
||||
|
||||
@Option(help: "Tell if it will generate xcStrings file or not")
|
||||
var xcStrings: Bool = false
|
||||
@Option(help: "Tell if it will generate xcStrings file or lproj file. True by default")
|
||||
var xcStrings: Bool = true
|
||||
|
||||
@Option(help: "Extension name. If not specified, it will generate an String extension.")
|
||||
var extensionName: String = Stringium.defaultExtensionName
|
||||
@Option(
|
||||
help: "Path where to generate the extension.",
|
||||
transform: { $0.replaceTiltWithHomeDirectoryPath() }
|
||||
)
|
||||
var extensionOutputPath: String?
|
||||
|
||||
@Option(help: "Extension name. If not specified, no extension will be generated.")
|
||||
var extensionName: String?
|
||||
|
||||
@Option(help: "Extension suffix: {extensionName}+{extensionSuffix}.swift")
|
||||
var extensionSuffix: String
|
||||
var extensionSuffix: String?
|
||||
}
|
||||
|
||||
// MARK: - Private var getter
|
||||
@ -75,12 +91,21 @@ extension StringiumOptions {
|
||||
|
||||
extension StringiumOptions {
|
||||
|
||||
var extensionFileName: String {
|
||||
"\(extensionName)+\(extensionSuffix).swift"
|
||||
private var extensionFileName: String? {
|
||||
if let extensionName {
|
||||
if let extensionSuffix {
|
||||
return "\(extensionName)+\(extensionSuffix).swift"
|
||||
}
|
||||
return "\(extensionName).swift"
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var extensionFilePath: String {
|
||||
"\(extensionOutputPath)/\(extensionFileName)"
|
||||
var extensionFilePath: String? {
|
||||
if let extensionOutputPath, let extensionFileName {
|
||||
return "\(extensionOutputPath)/\(extensionFileName)"
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var inputFilenameWithoutExt: String {
|
||||
@ -88,4 +113,12 @@ extension StringiumOptions {
|
||||
.deletingPathExtension()
|
||||
.lastPathComponent
|
||||
}
|
||||
|
||||
var xcStringsFilePath: String {
|
||||
"\(stringsFileOutputPath)/\(inputFilenameWithoutExt).xcstrings"
|
||||
}
|
||||
|
||||
var lprojPathFormat: String {
|
||||
"\(stringsFileOutputPath)/%@.lproj/\(inputFilenameWithoutExt).strings"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user