View Javadoc

1   package org.lsst.ccs.shell;
2   
3   import java.io.IOException;
4   import java.util.List;
5   import jline.console.ConsoleReader;
6   import jline.console.completer.CandidateListCompletionHandler;
7   
8   /**
9    * Extend JLine's built-in completion handler to handle giving
10   * information on specific parameters. 
11   * @author tonyj
12   */
13  class CommandCompletionHandler extends CandidateListCompletionHandler {
14  
15      @Override
16      public boolean complete(ConsoleReader reader, List<CharSequence> candidates, int pos) throws IOException {
17          //FIXME: Using # to indicate parameter help is ugly
18          if (candidates.size() == 1 && candidates.get(0).length()>1 && candidates.get(0).charAt(0)=='#') {
19              reader.println();
20              reader.println(candidates.get(0).subSequence(1, candidates.get(0).length()));
21              reader.drawLine();
22              return true;
23          } else {
24              return super.complete(reader, candidates, pos);
25          }
26      }
27  
28      
29  }