|
18 | 18 | import java.io.File; |
19 | 19 | import java.nio.file.Files; |
20 | 20 | import java.util.List; |
| 21 | +import java.util.Map; |
21 | 22 |
|
22 | 23 | import org.jetbrains.annotations.NotNull; |
23 | 24 |
|
|
36 | 37 |
|
37 | 38 | import picocli.CommandLine; |
38 | 39 |
|
39 | | -@CommandLine.Command(name = "license-header", description = "Runs license header") |
| 40 | +@CommandLine.Command( |
| 41 | + name = "license-header", |
| 42 | + description = "Runs license header", |
| 43 | + defaultValueProvider = LicenseHeader.OptionDefaultProvider.class) |
40 | 44 | @SupportedFileTypes("any") |
41 | 45 | @AdditionalInfoLinks("https://github.com/diffplug/spotless/tree/main/plugin-gradle#license-header") |
42 | 46 | public class LicenseHeader extends SpotlessFormatterStep { |
| 47 | + |
| 48 | + static class OptionDefaultProvider extends OptionDefaultValueProvider { |
| 49 | + OptionDefaultProvider() { |
| 50 | + super(Map.of(OPTION_YEAR_SEPARATOR_LONG, LicenseHeaderStep::defaultYearDelimiter)); |
| 51 | + } |
| 52 | + } |
| 53 | + |
43 | 54 | @CommandLine.ArgGroup(exclusive = true, multiplicity = "1") |
44 | 55 | LicenseHeaderSourceOption licenseHeaderSourceOption; |
45 | 56 |
|
@@ -73,10 +84,13 @@ static class LicenseHeaderSourceOption { |
73 | 84 | + OptionConstants.VALID_AND_DEFAULT_VALUES_SUFFIX) |
74 | 85 | LicenseHeaderStep.YearMode yearMode; |
75 | 86 |
|
| 87 | + private static final String OPTION_YEAR_SEPARATOR_LONG = "--year-separator"; |
| 88 | + private static final String OPTION_YEAR_SEPARATOR_SHORT = "-Y"; |
| 89 | + |
76 | 90 | @CommandLine.Option( |
77 | | - names = {"--year-separator", "-Y"}, |
| 91 | + names = {OPTION_YEAR_SEPARATOR_LONG, OPTION_YEAR_SEPARATOR_SHORT}, |
78 | 92 | required = false, |
79 | | - defaultValue = "-" /* TODO simschla: Make accessible: LicenseHeaderStep.DEFAULT_YEAR_DELIMITER*/, |
| 93 | + // defaultValue from DefaultValueProvider (because is dynamic) |
80 | 94 | description = "The separator to use for the year range in the license header." |
81 | 95 | + OptionConstants.DEFAULT_VALUE_SUFFIX) |
82 | 96 | String yearSeparator; |
|
0 commit comments