implement option parameter

This commit is contained in:
serizawa 2024-10-31 19:16:06 +09:00
parent f244530932
commit bc4be44174

View File

@ -248,17 +248,34 @@ public class BioFormatsImageInfo {
boolean status = true; boolean status = true;
String message = ""; String message = "";
String format = ""; String format = "";
boolean metadataON = true;
boolean thumbnailON = true;
String path = "";
final Map<String, Object> metadata = new LinkedHashMap<String, Object>(); final Map<String, Object> metadata = new LinkedHashMap<String, Object>();
final Map<String, Object> thumbnail = new LinkedHashMap<String, Object>(); final Map<String, Object> thumbnail = new LinkedHashMap<String, Object>();
if (args.length != 1) { if (args.length == 1) {
status = false; path = args[0];
message = "filename argument required"; } else if (args.length == 2) {
if (args[0].startsWith("-")) {
metadataON = args[0].toUpperCase().contains("M");
thumbnailON = args[0].toUpperCase().contains("T");
}
path = args[1];
} else { } else {
final String path = args[0]; status = false;
message = "invalid parameters";
message += "\nUsage ./target/dist/bin/bioformats-imageinfo \"[OPTION]\" \"[path to image file]\"";
message += "\n-M output metadata\n-T output thumbnail";
}
if (status) {
try { try {
DebugTools.enableLogging("OFF"); DebugTools.enableLogging("OFF");
format = readMetadata(path, metadata); if (metadataON) {
BioFormatsImageThumbnail.readThumbnail(path, thumbnail); format = readMetadata(path, metadata);
}
if (thumbnailON) {
BioFormatsImageThumbnail.readThumbnail(path, thumbnail);
}
} catch (Throwable t) { } catch (Throwable t) {
status = false; status = false;
message = t.getMessage(); message = t.getMessage();