nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.92k stars 639 forks source link

Add file header placeholders for user who created the file #1500

Closed hampustagerud closed 1 year ago

hampustagerud commented 1 year ago

Hi! Thank you for this tool, it helps tremendously when working on Swift projects 🙏

When setting up a configuration for a project where I want to generate the header I noticed that the "Created by" row is hard to keep as generated by Xcode, so I thought {created.name} and {created.email} could be a nice addition to the templating 🙂

The PR reworks the templating a bit to make it more loop-based, which could make it easier to add more placeholders later if needed.

It also fixes a bug where each placeholder could only be used once.

Related issue: #776

codecov[bot] commented 1 year ago

Codecov Report

Merging #1500 (960b770) into develop (532d8a5) will decrease coverage by 0.26%. The diff coverage is 55.81%.

@@             Coverage Diff             @@
##           develop    #1500      +/-   ##
===========================================
- Coverage    95.16%   94.91%   -0.26%     
===========================================
  Files           18       20       +2     
  Lines        20981    21064      +83     
===========================================
+ Hits         19967    19993      +26     
- Misses        1014     1071      +57     
Files Changed Coverage Δ
Sources/GitHelpers.swift 0.00% <0.00%> (ø)
Sources/ParsingHelpers.swift 96.81% <ø> (-0.02%) :arrow_down:
Sources/ShellHelpers.swift 0.00% <0.00%> (ø)
Sources/CommandLine.swift 69.84% <100.00%> (+0.08%) :arrow_up:
Sources/FormattingHelpers.swift 97.76% <100.00%> (+0.01%) :arrow_up:
Sources/Options.swift 96.00% <100.00%> (+0.28%) :arrow_up:
Sources/Rules.swift 98.41% <100.00%> (-0.01%) :arrow_down:
Sources/SwiftFormat.swift 89.88% <100.00%> (+0.18%) :arrow_up:
nicklockwood commented 1 year ago

Thanks, this looks great! I might tweak the option names to be a bit less verbose, but it seems like a cool feature.

Ramiz69 commented 8 months ago

doesn't work

Screenshot 2024-03-02 at 11 13 42 PM
nicklockwood commented 8 months ago

@Ramiz69 it's not been released yet. The feature is only available in the develop branch currently.

tahirmt commented 5 months ago

@nicklockwood Has this been released yet? I'm not able to use it.

nicklockwood commented 5 months ago

Not yet - sorry for the delay, I want to make some tweaks to the naming before it ships

tahirmt commented 5 months ago

@nicklockwood any idea when it will be released?