@Argument(name = "name", description = "Name of created zip or directory", required = false)
String fileName;
@Override
protected Object doExecute() throws Exception {
DumpDestination destination;
if (providers.isEmpty()) {
session.getConsole().println("Unable to create dump. No providers were found");
return null;
}
// create default file name if none provided
if (fileName == null || fileName.trim().length() == 0) {
fileName = SimpleDateFormat.getDateTimeInstance().format(new Date());
if (!directory) {
fileName += ".zip";
}
}
File target = new File(fileName);
// if directory switch is on, create dump in directory
if (directory) {
destination = new DirectoryDumpDestination(target);
} else {
destination = new ZipDumpDestination(target);
}
for (DumpProvider provider : providers) {
provider.createDump(destination);
}
destination.save();
session.getConsole().println("Diagnostic dump created.");
return null;
}