upassword: possibilité de spécifier de façon dynamique la ligne à afficher après
This commit is contained in:
parent
295af1de28
commit
a74a37392a
25
upassword
25
upassword
|
@ -5091,24 +5091,27 @@ public class upassword {
|
||||||
|
|
||||||
private static final Pattern SPACES = Pattern.compile("\\s+");
|
private static final Pattern SPACES = Pattern.compile("\\s+");
|
||||||
|
|
||||||
|
private static final String BATCH_OPTION = "--batch";
|
||||||
|
|
||||||
|
private static final String AFTER_COMMAND = BATCH_OPTION + "-after ";
|
||||||
|
|
||||||
|
private static final int AFTER_COMMAND_STRIP = AFTER_COMMAND.length();
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
upassword upassword = new upassword();
|
upassword upassword = new upassword();
|
||||||
if (args.length > 0 && args[0].equals("--batch")) {
|
if (args.length > 0 && args[0].equals(BATCH_OPTION)) {
|
||||||
StringBuilder sb = new StringBuilder();
|
String after = null;
|
||||||
for (int i = 1; i < args.length; i++) {
|
|
||||||
if (i > 1) sb.append(" ");
|
|
||||||
sb.append(args[i]);
|
|
||||||
}
|
|
||||||
String after = sb.toString();
|
|
||||||
if (after.length() == 0) after = null;
|
|
||||||
|
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
||||||
try {
|
try {
|
||||||
while (true) {
|
while (true) {
|
||||||
String line = br.readLine();
|
String line = br.readLine();
|
||||||
if (line == null) break;
|
if (line == null) break;
|
||||||
upassword.run(SPACES.split(line));
|
if (line.startsWith(AFTER_COMMAND)) {
|
||||||
if (after != null) println(after);
|
after = line.substring(AFTER_COMMAND_STRIP);
|
||||||
|
} else {
|
||||||
|
upassword.run(SPACES.split(line));
|
||||||
|
if (after != null) println(after);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
die(null, e);
|
die(null, e);
|
||||||
|
|
Loading…
Reference in New Issue