Skip to content

Commit

Permalink
Merge pull request #7 from jjotaum/feature/generator-enhancements
Browse files Browse the repository at this point in the history
Generator Enhancements
  • Loading branch information
jjotaum authored Jul 17, 2020
2 parents 1e9d4b3 + 939cbbe commit 1f640bb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
12 changes: 11 additions & 1 deletion Application/Generator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ extension Generator {
let file = File(named: name, at: folder)
let body = folder.colorDefinitions(for: platform).joined(separator: "\n\n")
let content = platform.fileContent(header: header, body: body)
try? file.write(content)
do {
try file.write(content)
print(
"""
\(file.name) was generated successfully.
Can be found at \(folder.path)
"""
)
} catch {
print(error.localizedDescription)
}
}
}
11 changes: 9 additions & 2 deletions Application/Platform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,21 @@ extension Platform {
func colorVariable(name: String) -> String {
switch self {
case .iOS, .macOS:
return "static var \(name): \(variableType) { return \(variableType)(named: \"\(name)\")! }"
return " static var \(name): \(variableType) { return \(variableType)(named: \"\(name)\")! }"
case .swiftUI:
return "static var \(name): \(variableType) { return \(variableType)(\"\(name)\") }"
return " static var \(name): \(variableType) { return \(variableType)(\"\(name)\") }"
}
}

func fileContent(header: String, body: String) -> String {
"""
//
// Generated by Chroma.
// https://github.com/jjotaum/Chroma.
//
// This file was auto generated please do not modify it directly.
//
import \(framework)
\(header) {
Expand Down

0 comments on commit 1f640bb

Please sign in to comment.