Skip to content

Commit 00a8462

Browse files
committed
Resolve comments
1 parent 370ab78 commit 00a8462

File tree

2 files changed

+6
-34
lines changed

2 files changed

+6
-34
lines changed

Sources/swift-openapi-generator/GenerateCommand.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct _GenerateCommand: AsyncParsableCommand {
4747
"Whether this invocation is from the SwiftPM plugin. We always need to produce all files when invoked from the plugin. Non-requested modes produce empty files."
4848
)
4949
var isPluginInvocation: Bool = false
50-
50+
5151
@Flag(
5252
help:
5353
"Simulate the command and print the operations, without actually affecting the file system."

Sources/swift-openapi-generator/runGenerator.swift

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,6 @@ import ArgumentParser
1616
import _OpenAPIGeneratorCore
1717

1818
extension _Tool {
19-
20-
/// A structure that defines ANSI escape codes for different colors in the terminal output.
21-
///
22-
/// You can use these codes to change the color of the text printed by the `print` function or other methods that write to the standard output. To reset the text color to the default, use the `reset` code.
23-
///
24-
/// For example, to print "Hello" in red and "World" in green, you can use:
25-
/// ```swift
26-
/// print(
27-
/// CommandLineColors.red +
28-
/// "Hello" +
29-
/// CommandLineColors.green +
30-
/// "World" +
31-
/// CommandLineColors.reset
32-
/// )
33-
/// ```
34-
struct CommandLineColors {
35-
/// The ANSI escape code for resetting the text color and style to the default.
36-
static let reset = "\u{001B}[0;0m"
37-
/// The ANSI escape code for changing the text color to red.
38-
static let red = "\u{001B}[0;31m"
39-
/// The ANSI escape code for changing the text color to green.
40-
static let green = "\u{001B}[0;32m"
41-
}
42-
43-
4419
/// Runs the generator with the specified configuration values.
4520
/// - Parameters:
4621
/// - doc: A path to the OpenAPI document.
@@ -110,7 +85,7 @@ extension _Tool {
11085
isDryRun: Bool,
11186
diagnostics: any DiagnosticCollector
11287
) throws {
113-
let didChange = try replaceFileContents(
88+
try replaceFileContents(
11489
at: outputFilePath,
11590
with: {
11691
let output = try _OpenAPIGeneratorCore.runGenerator(
@@ -122,9 +97,6 @@ extension _Tool {
12297
},
12398
isDryRun: isDryRun
12499
)
125-
if !isDryRun {
126-
print("File \(outputFilePath.lastPathComponent): \(didChange ? "changed" : "unchanged")")
127-
}
128100
}
129101

130102
/// Evaluates a closure to generate file data and writes the data to disk
@@ -148,17 +120,17 @@ extension _Tool {
148120
let existingData = try? Data(contentsOf: path)
149121
didChange = existingData != data
150122
if didChange {
151-
print(CommandLineColors.red + "File \(path.lastPathComponent) will be overwritten." + CommandLineColors.reset)
123+
print("File \(path.lastPathComponent) will be overwritten.")
152124
} else {
153-
print(CommandLineColors.green + "File \(path.lastPathComponent) will remain unchanged." + CommandLineColors.reset)
125+
print("File \(path.lastPathComponent) will remain unchanged.")
154126
}
155127
} else {
156-
print(CommandLineColors.green + "File \(path.lastPathComponent) does not exist.\nCreating new file..." + CommandLineColors.reset)
128+
print("File \(path.lastPathComponent) does not exist.\nCreating new file...")
157129
didChange = true
158130
}
159131
if didChange {
160132
if isDryRun {
161-
print(CommandLineColors.green + "Writing data to \(path.lastPathComponent)..." + CommandLineColors.reset)
133+
print("Writing data to \(path.lastPathComponent)...")
162134
} else {
163135
try data.write(to: path)
164136
}

0 commit comments

Comments
 (0)