@Override public boolean isSet(Option option) { Boolean b = options.get(option); return b != null ? b : option.isDef(); }
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 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); } }
private static void setVar(LineReader reader, String key, String val) { if (LineReader.KEYMAP.equalsIgnoreCase(key)) { reader.setKeyMap(val); return; } for (LineReader.Option option : LineReader.Option.values()) { if (option.name().toLowerCase(Locale.ENGLISH).replace('_', '-').equals(val)) { if ("on".equalsIgnoreCase(val)) { reader.setOpt(option); } else if ("off".equalsIgnoreCase(val)) { reader.unsetOpt(option); } return; } } reader.setVariable(key, val); }
private static void setVar(LineReader reader, String key, String val) { if (LineReader.KEYMAP.equalsIgnoreCase(key)) { reader.setKeyMap(val); return; } for (LineReader.Option option : LineReader.Option.values()) { if (option.name().toLowerCase(Locale.ENGLISH).replace('_', '-').equals(val)) { if ("on".equalsIgnoreCase(val)) { reader.setOpt(option); } else if ("off".equalsIgnoreCase(val)) { reader.unsetOpt(option); } return; } } reader.setVariable(key, val); }