Add CLI usage details
This commit is contained in:
parent
68efc348bd
commit
306bb78c61
|
@ -19,14 +19,34 @@ public class AnalyzeDirectory {
|
|||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException, TikaException, SAXException {
|
||||
String directory = args[0];
|
||||
readFiles(directory);
|
||||
private static void usage() {
|
||||
System.out.println("Usage: AnalyzeDirectory <directory> <option>");
|
||||
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) {
|
||||
FileData data = new FileData(file);
|
||||
if (action == "metadata") {
|
||||
System.out.println(data);
|
||||
} else if (action == "links") {
|
||||
data.getLinks();
|
||||
} else {
|
||||
usage();
|
||||
}
|
||||
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]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue