Add CLI usage details

This commit is contained in:
coolneng 2020-10-25 21:38:21 +01:00
parent 68efc348bd
commit 306bb78c61
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
1 changed files with 24 additions and 4 deletions

View File

@ -19,14 +19,34 @@ public class AnalyzeDirectory {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
public static void main(String[] args) throws IOException, TikaException, SAXException { private static void usage() {
String directory = args[0]; System.out.println("Usage: AnalyzeDirectory <directory> <option>");
readFiles(directory); System.out.println("option metadata: shows the filename/file type/encoding and language of the files");
System.out.println("option links: shows all the links contained in each file");
System.exit(1);
}
private static void chooseAction(String action) {
for (File file : files) { for (File file : files) {
FileData data = new FileData(file); FileData data = new FileData(file);
if (action == "metadata") {
System.out.println(data); System.out.println(data);
} else if (action == "links") {
data.getLinks();
} else {
usage();
}
System.out.println("--------------------------------------------------------------------------"); System.out.println("--------------------------------------------------------------------------");
} }
} }
public static void main(String[] args) throws IOException, TikaException, SAXException {
if (args.length != 2) {
usage();
}
String directory = args[0];
readFiles(directory);
chooseAction(args[1]);
}
} }