Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

impr: use enum definitions to explain options in usage #374

Merged
merged 4 commits into from
Feb 13, 2025

Conversation

armcknight
Copy link
Contributor

Hi, first contribution here, thanks for making this tool available 👋🏻

I hadn't noticed what the options were for --report by only reading the usage help (xcbeautify -h), and saw what it was when reading the source. I figured it'd be nice to add that to the usage.

Then, I figured it'd be more maintainable if we used the enums themselves to describe to the help strings what the possible options are.

Thanks!

@armcknight
Copy link
Contributor Author

armcknight commented Feb 11, 2025

I was also pointed to https://github.com/apple/swift-argument-parser/blame/10d80282e5fb5ae41338b54aeee5c9c5efc102ce/Sources/ArgumentParser/Parsable%20Types/ExpressibleByArgument.swift#L30-L39 but it hasn't shipped in an official release of ArgumentParser yet.

Also because Renderer needs to be defined in XcbeautifyLib, I had to add public import ArgumentParser there. I don't know if there would be some undesirable implications of that.

Here's what it'd look like to make those changes from this branch: armcknight#2

Copy link
Owner

@cpisciotta cpisciotta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @armcknight 👋 This is great! Thank you for making this contribution and also linking to the upcoming Swift Argument Parser changes (TIL). I left a few comments, but otherwise LGTM!

@@ -34,7 +35,7 @@ struct Xcbeautify: ParsableCommand {

// swiftformat:disable redundantReturn

@Option(help: "Specify a renderer to format raw xcodebuild output ( options: terminal | github-actions | teamcity | azure-devops-pipelines).")
@Option(help: "Specify a renderer to format raw xcodebuild output. (Options: \(Renderer.optionsDescription)). (Default: terminal).")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... terminal is not actually the default value (e.g. if we're running via GitHub Actions). I wonder if there's a succinct way for us to explain that renderer is computed based on environment values and uses terminal as a fallback. Any other ideas?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to report that there is also a property ExpressibleByArgument.defaultValueDescription already available that can cover this use case:

image image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now though, I'll just leave it as it was in the past, with no default stated in the usage.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice – another TIL! Looking forward to the new Swift Argument Parser release, whenever the happens 🙄, but I agree leaving without default info is probably the best choice until then. Thanks!

Copy link

codecov bot commented Feb 11, 2025

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 91.20%. Comparing base (ac0ed6c) to head (acebc3d).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
Sources/XcbeautifyLib/Constants.swift 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #374      +/-   ##
==========================================
+ Coverage   90.91%   91.20%   +0.29%     
==========================================
  Files          17       18       +1     
  Lines        2454     2444      -10     
==========================================
- Hits         2231     2229       -2     
+ Misses        223      215       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cpisciotta
Copy link
Owner

@armcknight You can auto-fix the SwiftFormat issues with make format.

@armcknight
Copy link
Contributor Author

Thanks for reviewing, good suggestions @cpisciotta , ready!

Copy link
Owner

@cpisciotta cpisciotta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @armcknight 👏 Thanks so much for your contribution!

@cpisciotta cpisciotta merged commit 3f2c8f9 into cpisciotta:main Feb 13, 2025
14 of 15 checks passed
@cpisciotta
Copy link
Owner

@armcknight This is available starting with 2.25.0. Homebrew should pick it up shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants