Add --project-directory option to generate command to easily use relative path
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
This commit is contained in:
@ -0,0 +1,18 @@
|
||||
//
|
||||
// StringExtensions.swift
|
||||
//
|
||||
//
|
||||
// Created by Thibaut Schmitt on 31/08/2022.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
extension String {
|
||||
|
||||
func prependIfRelativePath(_ prependPath: String) -> String {
|
||||
if self.hasPrefix("/") {
|
||||
return self
|
||||
}
|
||||
return prependPath + self
|
||||
}
|
||||
}
|
@ -40,13 +40,17 @@ struct Generate: ParsableCommand {
|
||||
print(" - \(configuration.strings.count) strings configuration")
|
||||
print(" - \(configuration.tags.count) tags configuration")
|
||||
print()
|
||||
|
||||
print("Input file: \(configuration.colors.first?.inputFile ?? "no input file")")
|
||||
|
||||
// Execute commands
|
||||
configuration.runnableConfigurations
|
||||
.forEach {
|
||||
$0.run(force: options.forceGeneration)
|
||||
$0.run(projectDirectory: options.projectDirectory,
|
||||
force: options.forceGeneration)
|
||||
print("\n")
|
||||
}
|
||||
|
||||
|
||||
print("[\(Self.toolName)] Resgen ended")
|
||||
}
|
||||
}
|
||||
|
@ -16,4 +16,13 @@ struct GenerateOptions: ParsableArguments {
|
||||
|
||||
@Argument(help: "Configuration file.", transform: { $0.replaceTiltWithHomeDirectoryPath() })
|
||||
var configurationFile: String
|
||||
|
||||
@Option(help: "Project directory. It will be added to every relative path (path that does not start with `/`",
|
||||
transform: {
|
||||
if $0.last == "/" {
|
||||
return $0
|
||||
}
|
||||
return $0 + "/"
|
||||
})
|
||||
var projectDirectory: String
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// ColorsConfiguration+ShellCommandable.swift
|
||||
// ColorsConfiguration+Runnable.swift
|
||||
//
|
||||
//
|
||||
// Created by Thibaut Schmitt on 30/08/2022.
|
||||
@ -8,7 +8,7 @@
|
||||
import Foundation
|
||||
|
||||
extension ColorsConfiguration: Runnable {
|
||||
func run(force: Bool) {
|
||||
func run(projectDirectory: String, force: Bool) {
|
||||
var args = [String]()
|
||||
|
||||
if force {
|
||||
@ -16,13 +16,13 @@ extension ColorsConfiguration: Runnable {
|
||||
}
|
||||
|
||||
args += [
|
||||
inputFile,
|
||||
inputFile.prependIfRelativePath(projectDirectory),
|
||||
"--style",
|
||||
style,
|
||||
"--xcassets-path",
|
||||
xcassetsPath,
|
||||
xcassetsPath.prependIfRelativePath(projectDirectory),
|
||||
"--extension-output-path",
|
||||
extensionOutputPath,
|
||||
extensionOutputPath.prependIfRelativePath(projectDirectory),
|
||||
"--static-members",
|
||||
"\(staticMembersOptions)"
|
||||
]
|
||||
@ -39,7 +39,8 @@ extension ColorsConfiguration: Runnable {
|
||||
extensionSuffix
|
||||
]
|
||||
}
|
||||
|
||||
Colors.main(args)
|
||||
print("Colors args:")
|
||||
dump(args)
|
||||
//Colors.main(args)
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// FontsConfiguration+ShellCommandable.swift
|
||||
// FontsConfiguration+Runnable.swift
|
||||
//
|
||||
//
|
||||
// Created by Thibaut Schmitt on 30/08/2022.
|
||||
@ -8,7 +8,7 @@
|
||||
import Foundation
|
||||
|
||||
extension FontsConfiguration: Runnable {
|
||||
func run(force: Bool) {
|
||||
func run(projectDirectory: String, force: Bool) {
|
||||
var args = [String]()
|
||||
|
||||
if force {
|
||||
@ -18,7 +18,7 @@ extension FontsConfiguration: Runnable {
|
||||
args += [
|
||||
inputFile,
|
||||
"--extension-output-path",
|
||||
extensionOutputPath,
|
||||
extensionOutputPath.prependIfRelativePath(projectDirectory),
|
||||
"--static-members",
|
||||
"\(staticMembersOptions)"
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// ImagesConfiguration+ShellCommandable.swift
|
||||
// ImagesConfiguration+Runnable.swift
|
||||
//
|
||||
//
|
||||
// Created by Thibaut Schmitt on 30/08/2022.
|
||||
@ -8,7 +8,7 @@
|
||||
import Foundation
|
||||
|
||||
extension ImagesConfiguration: Runnable {
|
||||
func run(force: Bool) {
|
||||
func run(projectDirectory: String, force: Bool) {
|
||||
var args = [String]()
|
||||
|
||||
if force {
|
||||
@ -16,11 +16,11 @@ extension ImagesConfiguration: Runnable {
|
||||
}
|
||||
|
||||
args += [
|
||||
inputFile,
|
||||
inputFile.prependIfRelativePath(projectDirectory),
|
||||
"--xcassets-path",
|
||||
xcassetsPath,
|
||||
xcassetsPath.prependIfRelativePath(projectDirectory),
|
||||
"--extension-output-path",
|
||||
extensionOutputPath,
|
||||
extensionOutputPath.prependIfRelativePath(projectDirectory),
|
||||
"--static-members",
|
||||
"\(staticMembersOptions)"
|
||||
]
|
||||
|
@ -8,6 +8,6 @@
|
||||
import Foundation
|
||||
|
||||
protocol Runnable {
|
||||
func run(force: Bool)
|
||||
func run(projectDirectory: String, force: Bool)
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// StringsConfiguration+ShellCommandable.swift
|
||||
// StringsConfiguration+Runnable.swift
|
||||
//
|
||||
//
|
||||
// Created by Thibaut Schmitt on 30/08/2022.
|
||||
@ -8,7 +8,7 @@
|
||||
import Foundation
|
||||
|
||||
extension StringsConfiguration: Runnable {
|
||||
func run(force: Bool) {
|
||||
func run(projectDirectory: String, force: Bool) {
|
||||
var args = [String]()
|
||||
|
||||
if force {
|
||||
@ -16,15 +16,15 @@ extension StringsConfiguration: Runnable {
|
||||
}
|
||||
|
||||
args += [
|
||||
inputFile,
|
||||
inputFile.prependIfRelativePath(projectDirectory),
|
||||
"--output-path",
|
||||
outputPath,
|
||||
outputPath.prependIfRelativePath(projectDirectory),
|
||||
"--langs",
|
||||
langs,
|
||||
"--default-lang",
|
||||
defaultLang,
|
||||
"--extension-output-path",
|
||||
extensionOutputPath,
|
||||
extensionOutputPath.prependIfRelativePath(projectDirectory),
|
||||
"--static-members",
|
||||
"\(staticMembersOptions)"
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// TagsConfiguration+ShellCommandable.swift
|
||||
// TagsConfiguration+Runnable.swift
|
||||
//
|
||||
//
|
||||
// Created by Thibaut Schmitt on 30/08/2022.
|
||||
@ -8,7 +8,7 @@
|
||||
import Foundation
|
||||
|
||||
extension TagsConfiguration: Runnable {
|
||||
func run(force: Bool) {
|
||||
func run(projectDirectory: String, force: Bool) {
|
||||
var args = [String]()
|
||||
|
||||
if force {
|
||||
@ -16,11 +16,11 @@ extension TagsConfiguration: Runnable {
|
||||
}
|
||||
|
||||
args += [
|
||||
inputFile,
|
||||
inputFile.prependIfRelativePath(projectDirectory),
|
||||
"--lang",
|
||||
lang,
|
||||
"--extension-output-path",
|
||||
extensionOutputPath,
|
||||
extensionOutputPath.prependIfRelativePath(projectDirectory),
|
||||
"--static-members",
|
||||
"\(staticMembersOptions)"
|
||||
]
|
||||
|
Reference in New Issue
Block a user