|
21 | 21 | import org.slf4j.LoggerFactory; |
22 | 22 |
|
23 | 23 | import java.io.PrintWriter; |
| 24 | +import java.util.Arrays; |
24 | 25 |
|
25 | 26 | public class ParameterParser { |
26 | 27 | private static final Logger logger = LoggerFactory.getLogger(ParameterParser.class); |
@@ -53,7 +54,7 @@ public Parameter getParam(String... commandArgs) { |
53 | 54 | .fileThreshold(getFileThreshold(cmd)) |
54 | 55 | .githubToken(cmd.getOptionValue("g")) |
55 | 56 | .diffPath(cmd.getOptionValue("d")) |
56 | | - .coveragePath(cmd.getOptionValue("c")) |
| 57 | + .coveragePath(Arrays.asList(cmd.getOptionValues("c"))) |
57 | 58 | .githubUrl(cmd.getOptionValue("u", IGitHubConstants.HOST_API)) |
58 | 59 | .repo(cmd.getOptionValue("r")) |
59 | 60 | .diffType(cmd.getOptionValue("diff-type")) |
@@ -86,62 +87,66 @@ private String getPrNumber(CommandLine cmd) { |
86 | 87 | private Options executeOption() { |
87 | 88 | Options commandOptions = new Options(); |
88 | 89 |
|
89 | | - Option diffPath = new Option("d", DIFF_OPTION, true, "diff file path(absolute recommend)"); |
90 | | - commandOptions.addOption(diffPath); |
| 90 | + commandOptions.addOption(Option.builder("d") |
| 91 | + .longOpt(DIFF_OPTION) |
| 92 | + .hasArg() |
| 93 | + .desc("diff file path(absolute recommend)") |
| 94 | + .build()); |
91 | 95 |
|
92 | | - Option githubToken = new Option("g", GITHUB_TOKEN_OPTION, true, "github oauth token"); |
93 | | - githubToken.setRequired(true); |
94 | | - commandOptions.addOption(githubToken); |
| 96 | + commandOptions.addOption(Option.builder("dt") |
| 97 | + .longOpt("diff-type") |
| 98 | + .hasArg() |
| 99 | + .desc("diff type (github | file)") |
| 100 | + .build()); |
| 101 | + |
| 102 | + commandOptions.addOption(Option.builder("g") |
| 103 | + .longOpt(GITHUB_TOKEN_OPTION) |
| 104 | + .required() |
| 105 | + .hasArg() |
| 106 | + .desc("github oauth token") |
| 107 | + .build()); |
95 | 108 |
|
96 | | - Option githubUrl = Option.builder("u") |
97 | | - .desc("The url when you working on github enterprise url. default is api.github.com").hasArg() |
| 109 | + commandOptions.addOption(Option.builder("u") |
98 | 110 | .longOpt("github-url") |
99 | | - .build(); |
100 | | - commandOptions.addOption(githubUrl); |
| 111 | + .hasArg() |
| 112 | + .desc("The url when you working on github enterprise url. default is api.github.com") |
| 113 | + .build()); |
101 | 114 |
|
102 | | - Option githubPrNum = Option.builder("p") |
103 | | - .desc("github pr number").hasArg() |
| 115 | + commandOptions.addOption(Option.builder("p") |
104 | 116 | .longOpt("pr") |
105 | | - .build(); |
106 | | - commandOptions.addOption(githubPrNum); |
| 117 | + .hasArg() |
| 118 | + .desc("github pr number") |
| 119 | + .build()); |
107 | 120 |
|
108 | | - Option githubRepo = Option.builder("r").required() |
109 | | - .desc("github repo").hasArg() |
| 121 | + commandOptions.addOption(Option.builder("r").required() |
110 | 122 | .longOpt("repo") |
111 | | - .build(); |
112 | | - commandOptions.addOption(githubRepo); |
113 | | - |
114 | | - Option thresholdOption = Option.builder("t").required() |
115 | | - .desc("coverage pass threshold").hasArg() |
116 | | - .longOpt(THRESHOLD_OPTION).type(Integer.class) |
117 | | - .build(); |
118 | | - commandOptions.addOption(thresholdOption); |
| 123 | + .hasArg() |
| 124 | + .desc("github repo") |
| 125 | + .build()); |
119 | 126 |
|
120 | | - Option coverReportPath = Option.builder("c") |
121 | | - .longOpt(COVERAGE_PATH_OPTION).hasArg() |
| 127 | + commandOptions.addOption(Option.builder("c") |
| 128 | + .longOpt(COVERAGE_PATH_OPTION) |
| 129 | + .hasArg() |
122 | 130 | .required() |
123 | | - .desc("coverage report path(absolute recommend)").build(); |
124 | | - commandOptions.addOption(coverReportPath); |
| 131 | + .desc("coverage report path(absolute recommend)") |
| 132 | + .build()); |
125 | 133 |
|
126 | | - Option coverReportType = Option.builder(COVERAGE_TYPE_OPTION) |
| 134 | + commandOptions.addOption(Option.builder(COVERAGE_TYPE_OPTION) |
127 | 135 | .hasArg() |
128 | 136 | .desc("coverage report type (jacoco | cobertura) default is jacoco") |
129 | | - .build(); |
130 | | - commandOptions.addOption(coverReportType); |
| 137 | + .build()); |
131 | 138 |
|
132 | | - Option fileThresholdOption = Option.builder("ft") |
133 | | - .longOpt("file-threshold") |
| 139 | + commandOptions.addOption(Option.builder("t").required() |
| 140 | + .longOpt(THRESHOLD_OPTION).type(Integer.class) |
134 | 141 | .hasArg() |
135 | | - .desc("coverage report type (jacoco | cobertura) default is jacoco") |
136 | | - .build(); |
137 | | - commandOptions.addOption(fileThresholdOption); |
| 142 | + .desc("coverage pass threshold") |
| 143 | + .build()); |
138 | 144 |
|
139 | | - Option diffType = Option.builder("dt") |
140 | | - .longOpt("diff-type") |
| 145 | + commandOptions.addOption(Option.builder("ft") |
| 146 | + .longOpt("file-threshold") |
141 | 147 | .hasArg() |
142 | | - .desc("diff type (github | file)") |
143 | | - .build(); |
144 | | - commandOptions.addOption(diffType); |
| 148 | + .desc("coverage report type (jacoco | cobertura) default is jacoco") |
| 149 | + .build()); |
145 | 150 |
|
146 | 151 | return commandOptions; |
147 | 152 | } |
|
0 commit comments