NSHipster / SwiftSyntaxHighlighter

A syntax highlighter for Swift code that uses SwiftSyntax to generate Pygments-compatible HTML.
https://nshipster.com/swiftsyntax/
MIT License
275 stars 12 forks source link

Allow --scheme to be passed when reading from stdin #4

Closed belkadan closed 4 years ago

belkadan commented 4 years ago

Previously, the decision of whether to read from stdin was based entirely on the number of arguments, but that doesn't allow for passing configuration options. Change the argument parser to use an optional positional argument for the input, and make the decision based on that instead.

I tried to match the existing coding style, but given the extent of the changes I made to CommandTest.swift I had to extrapolate a fair bit. Let me know if there's anything to do to bring it more in line.

mattt commented 4 years ago

Thanks so much for submitting this PR, @belkadan! Please let me know if there's any functionality missing for your particular use case. I'd be happy to help however I can.

I've been struggling to figure out the right pattern for handling standard input with swift-argument-parser. Something else I'd been looking at using isatty to distinguish piped standard input from running the command without any arguments. But for now, I think this is a fine approach.

Coding style-wise, everything looks great. I just pushed a few trivial changes. The only blocker is on my end — it looks like I didn't configure CI to run for PR branches. Lemme get that sorted and once I get a ✅, I'll get this merged in.

mattt commented 4 years ago

This is now available in swift-syntax-highlight 1.0.1

$ brew upgrade swift-syntax-highlight