Package org.crsh.shell.impl.command

Examples of org.crsh.shell.impl.command.ShellSession


                    // Execute sequentially the script
                    BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(source)));

                    // A bit nasty but well it's ok
                    ShellSession session = (ShellSession)consumer.getSession();

                    while (true) {
                      String request = reader.readLine();
                      if (request == null) {
                        break;
View Full Code Here


  public void main(
      InvocationContext<Object> context,
      @Argument(completer = ReplCompleter.class)
      @Usage("the optional repl name")
      String name) throws Exception {
    ShellSession session = (ShellSession)context.getSession();
    Repl current = session.getRepl();
    if (name != null) {
      if (name.equals(current.getLanguage().getName())) {
        context.provide("Using repl " + name);
      } else {
        Repl found = null;
        for (Language lang : session.getContext().getPlugins(Language.class)) {
          if (lang.getName().equals(name)) {
            if (lang.isActive()) {
              found = lang.getRepl();
              if (found != null) {
                break;
              } else {
                throw new ScriptException("Language " + name + " does not provide a repl");
              }
            } else {
              throw new ScriptException("Language " + name + " not active");
            }
          }
        }
        if (found != null) {
          session.setRepl(found);
          context.provide("Using repl " + name);
        } else {
          throw new ScriptException("Repl " + name + " not found");
        }
      }
    } else {

      //
      LinkedHashMap<Repl, Boolean> repls = new LinkedHashMap<Repl, Boolean>();
      repls.put(ScriptRepl.getInstance(), true);
      for (Language lang : session.getContext().getPlugins(Language.class)) {
        Repl repl = lang.getRepl();
        if (repl != null) {
          repls.put(repl, lang.isActive());
        }
      }
View Full Code Here

    }
  }

  @Override
  public Completion complete(ParameterDescriptor parameter, String prefix) throws Exception {
    ShellSession session = (ShellSession)context.getSession();
    Completion.Builder builder = Completion.builder(prefix);
    for (Language lang : session.getContext().getPlugins(Language.class)) {
      if (lang.isActive()) {
        if (lang.getRepl() != null) {
          String name = lang.getName();
          if (name.startsWith(prefix)) {
            builder.add(name.substring(prefix.length()), true);
View Full Code Here

TOP

Related Classes of org.crsh.shell.impl.command.ShellSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.