protected String getCurrentSubShell(Session session) { String s = (String) session.get(Session.SUBSHELL); if (s == null) { s = ""; } return s; }
protected String getCurrentSubShell(Session session) { String s = (String) session.get(Session.SUBSHELL); if (s == null) { s = ""; } return s; }
protected String getCompletionType(Session session) { String completion = (String) session.get(Session.COMPLETION_MODE); if (completion == null) { completion = Session.COMPLETION_MODE_GLOBAL; } return completion; }
protected String getCompletionType(Session session) { String completion = (String) session.get(Session.COMPLETION_MODE); if (completion == null) { completion = Session.COMPLETION_MODE_GLOBAL; } return completion; }
public static Map<String, String> getColorMap(Session session, String name, String def) { Object obj = session.get(name + "_COLORS"); String str = obj != null ? obj.toString() : null; if (str == null) { str = def; } String sep = str.matches("[a-z]{2}=[0-9]*(;[0-9]+)*(:[a-z]{2}=[0-9]*(;[0-9]+)*)*") ? ":" : " "; return Arrays.stream(str.split(sep)) .collect(Collectors.toMap(s -> s.substring(0, s.indexOf('=')), s -> s.substring(s.indexOf('=') + 1))); }
private static Map<String, String> getColorMap(Session session, String name, String def) { Object obj = session.get(name + "_COLORS"); String str = obj != null ? obj.toString() : null; if (str == null || !str.matches("[a-z]{2}=[0-9]*(;[0-9]+)*(:[a-z]{2}=[0-9]*(;[0-9]+)*)*")) { str = def; } return Arrays.stream(str.split(":")) .collect(Collectors.toMap(s -> s.substring(0, s.indexOf('=')), s -> s.substring(s.indexOf('=') + 1))); }
public static Map<String, String> getColorMap(Session session, String name, String def) { Object obj = session.get(name + "_COLORS"); String str = obj != null ? obj.toString() : null; if (str == null) { str = def; } String sep = str.matches("[a-z]{2}=[0-9]*(;[0-9]+)*(:[a-z]{2}=[0-9]*(;[0-9]+)*)*") ? ":" : " "; return Arrays.stream(str.split(sep)) .collect(Collectors.toMap(s -> s.substring(0, s.indexOf('=')), s -> s.substring(s.indexOf('=') + 1))); }
private static Map<String, String> getColorMap(Session session, String name, String def) { Object obj = session.get(name + "_COLORS"); String str = obj != null ? obj.toString() : null; if (str == null || !str.matches("[a-z]{2}=[0-9]*(;[0-9]+)*(:[a-z]{2}=[0-9]*(;[0-9]+)*)*")) { str = def; } return Arrays.stream(str.split(":")) .collect(Collectors.toMap(s -> s.substring(0, s.indexOf('=')), s -> s.substring(s.indexOf('=') + 1))); }
@Override public Object execute(Session session, List<Object> arguments) throws Exception { CommandSession cmdSession = (CommandSession) session.get(".commandSession"); return consumer.execute(cmdSession, arguments); } }
@Override public Object execute(Session session, List<Object> arguments) throws Exception { CommandSession cmdSession = (CommandSession) session.get(".commandSession"); return consumer.execute(cmdSession, arguments); } }
@Override public Object get(String name) { Object val = session.get(name); if (val == null && parent != null) { val = parent.get(name); } return val; }
@Override public Object execute(Session session, List<Object> arguments) throws Exception { CommandSession commandSession = (CommandSession) session.get(".commandSession"); return closure.execute(commandSession, arguments); }
@Override public Object execute() throws Exception { if (mode == null) { System.out.println(session.get(Session.COMPLETION_MODE)); } else if (!mode.equalsIgnoreCase("global") && !mode.equalsIgnoreCase("first") && !mode.equalsIgnoreCase("subshell")) { System.err.println("The completion mode is not correct. The valid modes are: global, first, subshell. See documentation for details."); } else { session.put(Session.COMPLETION_MODE, mode.toLowerCase()); } return null; }
@Override public Object execute(Session session, List<Object> arguments) throws Exception { // TODO: remove not really nice cast CommandSession commandSession = (CommandSession) session.get(".commandSession"); return oldCommand.execute(commandSession, arguments); } };
@Override public Object execute() throws Exception { if (mode == null) { System.out.println(session.get(Session.COMPLETION_MODE)); } else if (!mode.equalsIgnoreCase("global") && !mode.equalsIgnoreCase("first") && !mode.equalsIgnoreCase("subshell")) { System.err.println("The completion mode is not correct. The valid modes are: global, first, subshell. See documentation for details."); } else { session.put(Session.COMPLETION_MODE, mode.toLowerCase()); } return null; }
@Override public Object execute(Session session, List<Object> arguments) throws Exception { // TODO: remove not really nice cast CommandSession commandSession = (CommandSession) session.get(".commandSession"); return target.execute(commandSession, arguments); }
@Override public Object execute(Session session, List<Object> arguments) throws Exception { // TODO: remove not really nice cast CommandSession commandSession = (CommandSession) session.get(".commandSession"); return target.execute(commandSession, arguments); }
@Override public Object execute(Session session, List<Object> arguments) throws Exception { // TODO: remove not really nice cast CommandSession commandSession = (CommandSession) session.get(".commandSession"); return oldCommand.execute(commandSession, arguments); } };
protected Object doExecute() throws Exception { String oldPid = (String) this.session.get(PROPERTY_CONFIG_PID); if (oldPid != null && oldPid.equals(pid) && !force) { System.err.println("This config is being edited. Cancel / update first, or use the --force option"); return null; } this.configRepository.delete(pid); if (oldPid != null && oldPid.equals(pid) && !force) { this.session.put(PROPERTY_CONFIG_PID, null); this.session.put(PROPERTY_CONFIG_PROPS, null); } return null; }
@Override protected void doExecute(Session session) throws Exception { session.put(Session.SUBSHELL, name); session.put(Session.SCOPE, name + ":" + session.get(Session.SCOPE)); }