public static boolean isSet(LineReader reader, LineReader.Option option) { return reader != null && reader.isSet(option); }
protected void addHistoryLine(Path path, String line) { if (reader.isSet(LineReader.Option.HISTORY_TIMESTAMPED)) { int idx = line.indexOf(':'); if (idx < 0) { throw new IllegalArgumentException("Bad history file syntax! " + "The history file `" + path + "` may be an older history: " + "please remove it or use a different history file."); } Instant time = Instant.ofEpochMilli(Long.parseLong(line.substring(0, idx))); String unescaped = unescape(line.substring(idx + 1)); internalAdd(time, unescaped); } else { internalAdd(Instant.now(), unescape(line)); } }
private String format(Entry entry) { if (reader.isSet(LineReader.Option.HISTORY_TIMESTAMPED)) { return Long.toString(entry.time().toEpochMilli()) + ":" + escape(entry.line()) + "\n"; } return escape(entry.line()) + "\n"; }
public static void unsetopt(LineReader reader, PrintStream out, PrintStream err, String[] argv) { final String[] usage = { "unsetopt - unset options", "Usage: unsetopt [-m] option ...", " unsetopt", " -? --help Displays command help", " -m Use pattern matching" }; Options opt = Options.compile(usage).parse(argv); if (opt.isSet("help")) { opt.usage(err); return; } if (opt.args().isEmpty()) { for (Option option : Option.values()) { if (reader.isSet(option) == option.isDef()) { out.println((option.isDef() ? "no-" : "") + option.toString().toLowerCase().replace('_', '-')); } } } else { boolean match = opt.isSet("m"); doSetOpts(reader, out, err, opt.args(), match, false); } }
public static void setopt(LineReader reader, PrintStream out, PrintStream err, String[] argv) { final String[] usage = { "setopt - set options", "Usage: setopt [-m] option ...", " setopt", " -? --help Displays command help", " -m Use pattern matching" }; Options opt = Options.compile(usage).parse(argv); if (opt.isSet("help")) { opt.usage(err); return; } if (opt.args().isEmpty()) { for (Option option : Option.values()) { if (reader.isSet(option) != option.isDef()) { out.println((option.isDef() ? "no-" : "") + option.toString().toLowerCase().replace('_', '-')); } } } else { boolean match = opt.isSet("m"); doSetOpts(reader, out, err, opt.args(), match, true); } }
public static void setopt(LineReader reader, PrintStream out, PrintStream err, String[] argv) { final String[] usage = { "setopt - set options", "Usage: setopt [-m] option ...", " setopt", " -? --help Displays command help", " -m Use pattern matching" }; Options opt = Options.compile(usage).parse(argv); if (opt.isSet("help")) { opt.usage(err); return; } if (opt.args().isEmpty()) { for (Option option : Option.values()) { if (reader.isSet(option) != option.isDef()) { out.println((option.isDef() ? "no-" : "") + option.toString().toLowerCase().replace('_', '-')); } } } else { boolean match = opt.isSet("m"); doSetOpts(reader, out, err, opt.args(), match, true); } }
public static void unsetopt(LineReader reader, PrintStream out, PrintStream err, String[] argv) { final String[] usage = { "unsetopt - unset options", "Usage: unsetopt [-m] option ...", " unsetopt", " -? --help Displays command help", " -m Use pattern matching" }; Options opt = Options.compile(usage).parse(argv); if (opt.isSet("help")) { opt.usage(err); return; } if (opt.args().isEmpty()) { for (Option option : Option.values()) { if (reader.isSet(option) == option.isDef()) { out.println((option.isDef() ? "no-" : "") + option.toString().toLowerCase().replace('_', '-')); } } } else { boolean match = opt.isSet("m"); doSetOpts(reader, out, err, opt.args(), match, false); } }