Options added

J’ai des options pour… plein de trucs.
Encore des essais.
This commit is contained in:
F. Y. H. 2025-03-13 17:27:52 +01:00
commit 31ec7f7cdc
Signed by: Alnotz
GPG key ID: BB5A7B6724BF531A

View file

@ -5,6 +5,8 @@ import io.nayuki.qrcodegen.QrCode;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Iterator;
/**
* Hello world!
@ -12,22 +14,69 @@ import java.io.InputStreamReader;
*/
public class App
{
public static void main( String[] args ) throws IOException {
System.out.printf("QRCode version %s.%s\n",
QrCode.MAX_VERSION,
QrCode.MIN_VERSION);
System.out.printf("Size : %s\n", args.length);
if (args.length > 0 ) {
for (String arg: args) {
System.out.printf("Arg1 : %s\n", arg);
}
}
private static final String LICENCE = "jqrcode Copyright© 2025 Alnotz\n" +
"This program comes with ABSOLUTELY NO WARRANTY.\n" +
"This is free software, and you are welcome to redistribute it" +
" under certain\n conditions.\n";
private static final String VERSION = String.format("JQRCode v. 1.0\n" +
"QRCode v. %s.%s\n",
QrCode.MAX_VERSION,
QrCode.MIN_VERSION);
private static final String HELP = """
Usages:
jqrcode (-h | --help)
jqrcode (-V | --version)
jqrcode (-l | --licence)
jqrcode (-s | --say)
""";
private static String readInput() throws IOException {
BufferedReader input =
new BufferedReader(new InputStreamReader(System.in));
String text = "";
if (input.ready()) {
System.out.println("Pipe entry :");
for (Object line:input.lines().toArray()){
System.out.printf("%s\n", line);
for (String line: input.lines().toList()){
text += String.format("%s\n", line);
}
}
return text;
}
public static void main( String[] args ) throws IOException {
if (args.length > 0 ) {
final Iterator<String> argsIterator =
Arrays.stream(args).iterator();
while (argsIterator.hasNext()){
String arg = argsIterator.next();
switch (arg) {
case "-h":
case "--help":
System.out.println(HELP);
System.exit(0);
case "-s":
case "--say":
if(argsIterator.hasNext()) {
final String TEXT = argsIterator.next();
if (TEXT.equals("-")) {
System.out.print(readInput());
} else {
System.out.println(TEXT);
}
System.exit(0);
} else {
System.out.println("'--say' hasn't entry!");
System.exit(1);
}
case "-V":
case "--version":
System.out.print(VERSION);
System.exit(0);
case "-l":
case "--licence":
System.out.print(LICENCE);
System.exit(0);
}
}
}
}