Skip to content

Commit

Permalink
Use - instead of -- to read files from stdin.
Browse files Browse the repository at this point in the history
Adhere to GNU utils convention of using `-` for reading from stdin.
Also expand and adapt usage information.
  • Loading branch information
tstoeter committed Jun 27, 2024
1 parent 41922a8 commit a569f5a
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ public void printUsage() {
"",
" -version: print the library version and exit",
" file: the image file to read",
" reads file names line-wise from stdin if -- is passed",
" if - is passed, process multiple files",
" with file names read line-wise from stdin",
" -nopix: read metadata only, not pixels",
" -nocore: do not output core metadata",
" -nometa: do not parse format-specific metadata table",
Expand Down Expand Up @@ -1132,14 +1133,15 @@ public static void main(String[] args) throws Exception {
DebugTools.enableLogging("INFO");

List<String> argsList = Arrays.asList(args);
int idx = argsList.indexOf("--");
int idx = argsList.indexOf("-");

if (idx >= 0) {
Scanner scanner = new Scanner(System.in);
String[] newArgs = argsList.toArray(new String[0]);

while (scanner.hasNext()) {
newArgs[idx] = scanner.nextLine();
System.out.println("====% " + newArgs[idx]);
if (!new ImageInfo().testRead(newArgs)) System.exit(1);
}
scanner.close();
Expand All @@ -1150,3 +1152,4 @@ public static void main(String[] args) throws Exception {
}

}

0 comments on commit a569f5a

Please sign in to comment.