@Override protected void printHelp(Session session, PrintStream out) { try { new HelpCommand(session.getFactory()).execute(session, Arrays.asList("shell|" + name)); } catch (Exception e) { throw new RuntimeException("Unable to print subshell help", e); } } }
@Override protected void printHelp(Session session, PrintStream out) { try { new HelpCommand(session.getFactory()).execute(session, Arrays.asList("shell|" + name)); } catch (Exception e) { throw new RuntimeException("Unable to print subshell help", e); } } }
protected void discoverCommands(Session session, ClassLoader cl, String resource) throws IOException, ClassNotFoundException { Manager manager = new ManagerImpl(session.getRegistry(), session.getFactory().getRegistry(), true); Enumeration<URL> urls = cl.getResources(resource); while (urls.hasMoreElements()) { URL url = urls.nextElement(); BufferedReader r = new BufferedReader(new InputStreamReader(url.openStream())); String line = r.readLine(); while (line != null) { line = line.trim(); if (line.length() > 0 && line.charAt(0) != '#') { final Class<?> actionClass = cl.loadClass(line); manager.register(actionClass); } line = r.readLine(); } r.close(); } }
protected void discoverCommands(Session session, ClassLoader cl, String resource) throws IOException, ClassNotFoundException { Manager manager = new ManagerImpl(session.getRegistry(), session.getFactory().getRegistry(), true); Enumeration<URL> urls = cl.getResources(resource); while (urls.hasMoreElements()) { URL url = urls.nextElement(); BufferedReader r = new BufferedReader(new InputStreamReader(url.openStream())); String line = r.readLine(); while (line != null) { line = line.trim(); if (line.length() > 0 && line.charAt(0) != '#') { final Class<?> actionClass = cl.loadClass(line); manager.register(actionClass); } line = r.readLine(); } r.close(); } }
public String getHelp(Session session, String path) { if (path.indexOf('|') > 0) { if (path.startsWith("command|")) { path = path.substring("command|".length()); } else { return null; } } ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos, true); Session s = session.getFactory().create(bais, ps, ps, session); s.put(Session.SCOPE, session.get(Session.SCOPE)); s.put(Session.SUBSHELL, session.get(Session.SUBSHELL)); try { s.execute(path + " --help"); } catch (Throwable t) { return null; } finally { s.close(); } return baos.toString(); }
public String getHelp(Session session, String path) { if (path.indexOf('|') > 0) { if (path.startsWith("command|")) { path = path.substring("command|".length()); } else { return null; } } ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos, true); Session s = session.getFactory().create(bais, ps, ps, session); s.put(Session.SCOPE, session.get(Session.SCOPE)); s.put(Session.SUBSHELL, session.get(Session.SUBSHELL)); try { s.execute(path + " --help"); } catch (Throwable t) { return null; } finally { s.close(); } return baos.toString(); }
final Session newSession = session.getFactory().create( System.in, System.out, System.err, SuCommand.this.session.getTerminal(), null, null); Object oldIgnoreInterrupts = session.get(Session.IGNORE_INTERRUPTS);
final Session newSession = session.getFactory().create( System.in, System.out, System.err, SuCommand.this.session.getTerminal(), null, null); Object oldIgnoreInterrupts = session.get(Session.IGNORE_INTERRUPTS);