Skip to content

Commit

Permalink
Add ability to use - for output path
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriyvan committed Apr 18, 2024
1 parent 2a3ac77 commit e300672
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Sources/geometrize-cli/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ default:
}

let outputUrl = URL(fileURLWithPath: options.outputPath)
guard outputUrl.pathExtension.caseInsensitiveCompare("svg") == .orderedSame else {
guard options.outputPath == "-" || outputUrl.pathExtension.caseInsensitiveCompare("svg") == .orderedSame else {
print("Only SVG output file format is supported at the moment.")
exit(1)
}
Expand Down Expand Up @@ -141,7 +141,11 @@ while shapeData.count <= shapeCount {
let svg = SVGExporter().export(data: shapeData, width: width, height: height)

do {
try svg.write(to: outputUrl, atomically: true, encoding: .utf8)
if options.outputPath == "-" {
print(svg)
} else {
try svg.write(to: outputUrl, atomically: true, encoding: .utf8)
}
} catch {
print("Cannot write output file. \(error)")
}

0 comments on commit e300672

Please sign in to comment.