Bugs fixes, Lint fixes, Refactoring
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit

This commit is contained in:
2022-08-29 13:38:46 +02:00
parent e3f90e0d48
commit a54a264447
35 changed files with 652 additions and 401 deletions

View File

@ -10,19 +10,42 @@ import ToolCore
import ArgumentParser
struct Tags: ParsableCommand {
static var configuration = CommandConfiguration(abstract: "Generate tags extension file.")
// MARK: - Command Configuration
static var configuration = CommandConfiguration(
abstract: "Generate tags extension file.",
version: "0.1.0"
)
// MARK: - Static
static let toolName = "Tags"
static let defaultExtensionName = "Tags"
static let noTranslationTag: String = "notranslation"
var extensionFileName: String { "\(options.extensionName)+\(options.extensionSuffix).swift" }
// MARK: - Properties
var extensionFileName: String {
if options.extensionSuffix.isEmpty == false {
return "\(options.extensionName)+\(options.extensionSuffix).swift"
}
return "\(options.extensionName).swift"
}
var extensionFilePath: String { "\(options.extensionOutputPath)/\(extensionFileName)" }
var generateStaticVariable: Bool {
options.extensionName == Self.defaultExtensionName
}
// MARK: - Command Options
// The `@OptionGroup` attribute includes the flags, options, and
// arguments defined by another `ParsableArguments` type.
@OptionGroup var options: TagsOptions
// MARK: - Run
mutating func run() {
print("[\(Self.toolName)] Starting tagss generation")
@ -38,7 +61,7 @@ struct Tags: ParsableCommand {
TagsGenerator.writeExtensionFiles(sections: sections,
lang: options.lang,
tags: ["ios", "iosonly", Self.noTranslationTag],
staticVar: options.extensionName == Self.defaultExtensionName,
staticVar: generateStaticVariable,
extensionName: options.extensionName,
extensionFilePath: extensionFilePath)