resgen.swift/Sources/Strings/Stringium/StringiumOptions.swift
Thibaut Schmitt a54a264447
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
Bugs fixes, Lint fixes, Refactoring
2022-08-29 13:38:49 +02:00

61 lines
1.9 KiB
Swift

//
// StringiumOptions.swift
//
//
// Created by Thibaut Schmitt on 10/01/2022.
//
import Foundation
import ArgumentParser
struct StringiumOptions: ParsableArguments {
@Flag(name: [.customShort("f"), .customShort("F")], help: "Should force generation")
var forceGeneration = false
@Argument(help: "Input files where strings ared defined.", transform: { $0.replaceTiltWithHomeDirectoryPath() })
var inputFile: String
@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.")
fileprivate var langsRaw: String
@Option(help: "Default langs.")
var defaultLang: String
@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: "Extension name. If not specified, it will generate an String extension. Using default extension name will generate static property.")
var extensionName: String = Stringium.defaultExtensionName
@Option(help: "Extension suffix. Ex: MyApp, it will generate {extensionName}+{extensionSuffix}.swift")
var extensionSuffix: String = ""
}
extension StringiumOptions {
var stringsFileOutputPath: String {
var outputPath = outputPathRaw
if outputPath.last == "/" {
outputPath = String(outputPath.dropLast())
}
return outputPath
}
var langs: [String] {
langsRaw
.split(separator: " ")
.map { String($0) }
}
var tags: [String] {
tagsRaw
.split(separator: " ")
.map { String($0) }
}
}