Add stencil on color
This commit is contained in:
@ -41,12 +41,28 @@ struct ColorExtensionGenerator {
|
||||
staticVar: Bool,
|
||||
extensionName: String,
|
||||
isSwiftUI: Bool) -> String {
|
||||
[
|
||||
Self.getHeader(extensionClassname: extensionName, isSwiftUI: isSwiftUI),
|
||||
Self.getProperties(for: colors, withStaticVar: staticVar, isSwiftUI: isSwiftUI),
|
||||
Self.getFooter()
|
||||
]
|
||||
.joined(separator: "\n")
|
||||
// [
|
||||
// Self.getHeader(extensionClassname: extensionName, isSwiftUI: isSwiftUI),
|
||||
// Self.getProperties(for: colors, withStaticVar: staticVar, isSwiftUI: isSwiftUI),
|
||||
// Self.getFooter()
|
||||
// ]
|
||||
// .joined(separator: "\n")
|
||||
do {
|
||||
let context: [String: Any] = [
|
||||
"colors": colors,
|
||||
"isStatic": staticVar,
|
||||
"isSwiftUI": isSwiftUI,
|
||||
"toolName": Colors.toolName,
|
||||
"resgenVersion": ResgenSwiftVersion,
|
||||
"extensionClassname": extensionName
|
||||
]
|
||||
|
||||
return try ResgenSwift.environment.renderTemplate(name: "Colors/main_template", context: context)
|
||||
} catch {
|
||||
// let error = ColorsToolError.writeExtension(extensionFilePath, error.localizedDescription)
|
||||
// print(error.description)
|
||||
Colors.exit(withError: error)
|
||||
}
|
||||
}
|
||||
|
||||
private static func getHeader(extensionClassname: String, isSwiftUI: Bool) -> String {
|
||||
|
@ -8,6 +8,8 @@
|
||||
import ToolCore
|
||||
import Foundation
|
||||
import ArgumentParser
|
||||
import Stencil
|
||||
import PathKit
|
||||
|
||||
struct ResgenSwift: ParsableCommand {
|
||||
|
||||
@ -32,6 +34,20 @@ struct ResgenSwift: ParsableCommand {
|
||||
// subcommand is not given on the command line.
|
||||
//defaultSubcommand: Twine.self
|
||||
)
|
||||
|
||||
static let projectDirectory = URL(fileURLWithPath: #file) // ProjectDir/Sources/ResgenSwift/main.swift
|
||||
.deletingLastPathComponent() // ProjectDir/Sources/ResgenSwift/
|
||||
.deletingLastPathComponent() // ProjectDir/Sources/
|
||||
.deletingLastPathComponent() // ProjectDir/
|
||||
|
||||
static let environment = Environment(
|
||||
loader: FileSystemLoader(
|
||||
paths: [
|
||||
Path("\(projectDirectory.path)/Templates/")
|
||||
]
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
print(ResgenSwift.projectDirectory.path)
|
||||
ResgenSwift.main()
|
||||
|
Reference in New Issue
Block a user