Skip to content

Commit cfee080

Browse files
committed
Add cleanupFeatures option
1 parent 25eb207 commit cfee080

File tree

6 files changed

+37
-10
lines changed

6 files changed

+37
-10
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ usage: assertthat-bdd-standalone-1.9.6.jar
3030
-h,--help Display help
3131
-ignoreCertErrors <arg> Ignore ssl certificate eerors
3232
(default is false)
33+
-cleanupFeatures <arg> Delete features in outputFolder before download
34+
(default is true)
3335
-jiraServerUrl <arg> Jira server URL
3436
-jql <JQL> JQL filter for features and Jira
3537
ticket to be updated with report

src/main/java/com/assertthat/plugins/standalone/APIUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ public APIUtil(String projectId, String accessKey, String secretKey, String prox
7171
}
7272

7373
public File download(File targetDir, String mode, String jql,
74-
String tags, boolean isNumbered) throws IOException {
75-
if (targetDir.exists()) {
74+
String tags, boolean isNumbered, boolean cleanupFeatures) throws IOException {
75+
if (cleanupFeatures && targetDir.exists()) {
7676
for (File f : targetDir.listFiles()) {
7777
if (f.getName().endsWith(".feature")) {
7878
f.delete();

src/main/java/com/assertthat/plugins/standalone/Arguments.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public class Arguments {
4646
private boolean numbered;
4747
private boolean ignoreCertErrors;
4848

49+
private boolean cleanupFeatures = true;
50+
4951
Arguments(String accessKey,
5052
String secretKey,
5153
String projectId,
@@ -63,7 +65,8 @@ public class Arguments {
6365
String jiraServerUrl,
6466
String metadata,
6567
boolean numbered,
66-
boolean ignoreCertErrors) {
68+
boolean ignoreCertErrors,
69+
boolean cleanupFeatures) {
6770
this.accessKey = System.getenv("ASSERTTHAT_ACCESS_KEY");
6871
this.secretKey = System.getenv("ASSERTTHAT_SECRET_KEY");
6972
if (accessKey != null && !accessKey.trim().isEmpty()) {
@@ -108,6 +111,7 @@ public class Arguments {
108111
this.mode = mode;
109112
this.jql = jql;
110113
this.ignoreCertErrors = ignoreCertErrors;
114+
this.cleanupFeatures = cleanupFeatures;
111115
}
112116

113117
public boolean isIgnoreCertErrors() {
@@ -253,4 +257,12 @@ public boolean isNumbered() {
253257
public void setNumbered(boolean numbered) {
254258
this.numbered = numbered;
255259
}
260+
261+
public boolean isCleanupFeatures() {
262+
return cleanupFeatures;
263+
}
264+
265+
public void setCleanupFeatures(boolean cleanupFeatures) {
266+
this.cleanupFeatures = cleanupFeatures;
267+
}
256268
}

src/main/java/com/assertthat/plugins/standalone/ArgumentsFeatures.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public ArgumentsFeatures(String accessKey,
1414
String tags,
1515
String jiraServerUrl,
1616
boolean numbered,
17-
boolean ignoreCertErrors) {
17+
boolean ignoreCertErrors,
18+
boolean cleanupFeatures) {
1819
super(accessKey,
1920
secretKey,
2021
projectId,
@@ -32,6 +33,7 @@ public ArgumentsFeatures(String accessKey,
3233
jiraServerUrl,
3334
null,
3435
numbered,
35-
ignoreCertErrors);
36+
ignoreCertErrors,
37+
cleanupFeatures);
3638
}
3739
}

src/main/java/com/assertthat/plugins/standalone/ArgumentsReport.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ public ArgumentsReport(String accessKey,
3434
jiraServerUrl,
3535
metadata,
3636
false,
37-
ignoreCertErrors);
37+
ignoreCertErrors,
38+
false);
3839

3940
}
4041
}

src/main/java/com/assertthat/plugins/standalone/Main.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,15 @@ public static void main(String[] args) throws IOException, JSONException {
131131
options.addOption(numberedOption);
132132

133133
Option ignoreCertErrors = new Option("ignoreCertErrors", true, "Ignore ssl certificate eerors (default is false)");
134-
numberedOption.setRequired(false);
135-
numberedOption.setArgName("true|false");
134+
ignoreCertErrors.setRequired(false);
135+
ignoreCertErrors.setArgName("true|false");
136136
options.addOption(ignoreCertErrors);
137137

138+
Option cleanupFeatures = new Option("cleanupFeatures", true, "Delete features in outputFolder directory before downloading");
139+
cleanupFeatures.setRequired(false);
140+
cleanupFeatures.setArgName("true|false");
141+
options.addOption(cleanupFeatures);
142+
138143
Option reportOption = new Option("report", false, "Upload report");
139144
reportOption.setRequired(false);
140145

@@ -174,6 +179,10 @@ public static void main(String[] args) throws IOException, JSONException {
174179
if (cmd.hasOption("ignoreCertErrors") && cmd.getOptionValue("ignoreCertErrors") != null && cmd.getOptionValue("ignoreCertErrors").equals("true")) {
175180
ignoreCertErrorsVal = true;
176181
}
182+
boolean cleanupFeaturesVal = false;
183+
if (cmd.hasOption("cleanupFeatures") && cmd.getOptionValue("cleanupFeatures") != null && cmd.getOptionValue("cleanupFeatures").equals("true")) {
184+
cleanupFeaturesVal = true;
185+
}
177186
Arguments arguments = new Arguments(
178187
cmd.getOptionValue("accessKey"),
179188
cmd.getOptionValue("secretKey"),
@@ -192,7 +201,8 @@ public static void main(String[] args) throws IOException, JSONException {
192201
cmd.getOptionValue("jiraServerUrl"),
193202
cmd.getOptionValue("metadata"),
194203
ignoreCertErrorsVal,
195-
isNumbered
204+
isNumbered,
205+
cleanupFeaturesVal
196206
);
197207

198208
APIUtil apiUtil = new APIUtil(arguments.getProjectId(), arguments.getAccessKey(), arguments.getSecretKey(), arguments.getProxyURI(), arguments.getProxyUsername(), arguments.getProxyPassword(), arguments.getJiraServerUrl(), ignoreCertErrorsVal);
@@ -201,7 +211,7 @@ public static void main(String[] args) throws IOException, JSONException {
201211
File inZip =
202212
apiUtil.download(new File(arguments.getOutputFolder()),
203213
arguments.getMode(), arguments.getJql(),
204-
arguments.getTags(), arguments.isNumbered());
214+
arguments.getTags(), arguments.isNumbered(), arguments.isCleanupFeatures());
205215
File zip = new FileUtil().unpackArchive(inZip, new File(arguments.getOutputFolder()));
206216
zip.delete();
207217
}

0 commit comments

Comments
 (0)