Skip to content
Snippets Groups Projects
Commit 605a0a4c authored by Wei Liu's avatar Wei Liu
Browse files

add option to sort the result newest to oldest

parent 4bc98a51
Branches
Tags
No related merge requests found
......@@ -60,6 +60,9 @@ public class InstrumentUploadList implements MFCommand {
@Option(names = { "-c", "--compare" }, description = "Compare with local source file/directory.")
private boolean compare;
@Option(names = { "-n", "--newest-to-oldest" }, description = "Sort newest to oldest.")
private boolean newestToOldest;
@Option(names = { "-o",
"--output-csv" }, paramLabel = "<output.csv>", description = "Path to the output .csv file.")
private Path outputCSVFile;
......@@ -114,16 +117,15 @@ public class InstrumentUploadList implements MFCommand {
settings.setSrcPath(sp);
}
}
if (this.compare) {
settings.setCompare(compare);
}
settings.setCompare(this.compare);
settings.setNewestToOldest(this.newestToOldest);
if (this.outputCSVFile != null) {
settings.setOutputCSVFile(this.outputCSVFile);
}
Set<Upload> uploads = UploadShareable.findUploads(session, settings.shareableId(), settings.shareableToken(),
settings.after(), settings.before(), settings.shareWith(), settings.keywords(), settings.srcPath(),
true);
settings.newestToOldest());
if (!uploads.isEmpty()) {
if (settings.compare()) {
for (Upload upload : uploads) {
......@@ -132,7 +134,6 @@ public class InstrumentUploadList implements MFCommand {
}
System.out.println();
UploadShareable.printUploads(uploads, System.out);
if (settings.outputCSVFile() != null) {
UploadShareable.saveToCSVFile(session, uploads, settings.outputCSVFile(), settings.compare());
......@@ -150,6 +151,7 @@ public class InstrumentUploadList implements MFCommand {
private Date _after;
private Path _srcPath;
private boolean _compare = false;
private boolean _newestToOldest = false;
private Path _outputCSVFile;
Long shareableId() {
......@@ -184,6 +186,10 @@ public class InstrumentUploadList implements MFCommand {
return _compare;
}
boolean newestToOldest() {
return _newestToOldest;
}
Path outputCSVFile() {
return _outputCSVFile;
}
......@@ -238,6 +244,11 @@ public class InstrumentUploadList implements MFCommand {
return this;
}
public Settings setNewestToOldest(boolean newestToOldest) {
_newestToOldest = newestToOldest;
return this;
}
public Settings setOutputCSVFile(Path outputCSVFile) throws InterruptedException {
String name = outputCSVFile.getFileName().toString();
if (!name.toLowerCase().endsWith(".csv")) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment