Skip to content

Commit 8558ca8

Browse files
committed
Introduce Formatter
1 parent 145e55a commit 8558ca8

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

Sources/XcbeautifyLib/Formatter.swift

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import Foundation
2+
3+
public struct Formatter {
4+
private let parser: Parser
5+
6+
public init(
7+
colored: Bool = true,
8+
renderer: Renderer,
9+
preserveUnbeautifiedLines: Bool = false,
10+
additionalLines: @escaping () -> (String?)
11+
) {
12+
self.parser = Parser(
13+
colored: colored,
14+
renderer: renderer,
15+
preserveUnbeautifiedLines: preserveUnbeautifiedLines,
16+
additionalLines: additionalLines
17+
)
18+
}
19+
20+
public func parse(line: String) -> String? {
21+
parser.parse(line: line)
22+
}
23+
24+
}

Sources/XcbeautifyLib/Parser.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
public class Parser {
1+
package class Parser {
22
private let colored: Bool
33

44
private let renderer: OutputRendering
@@ -98,7 +98,7 @@ public class Parser {
9898

9999
// MARK: - Init
100100

101-
public init(
101+
package init(
102102
colored: Bool = true,
103103
renderer: Renderer,
104104
preserveUnbeautifiedLines: Bool = false,
@@ -117,7 +117,7 @@ public class Parser {
117117
self.additionalLines = additionalLines
118118
}
119119

120-
public func parse(line: String) -> String? {
120+
package func parse(line: String) -> String? {
121121
// Find first parser that can parse specified string
122122
guard let idx = captureGroupTypes.firstIndex(where: { $0.regex.match(string: line) }) else {
123123
// Some uncommon cases, which have additional logic and don't follow default flow

0 commit comments

Comments
 (0)