Ejemplo n.º 1
0
 public CommandThread fork(CommandShell shell, BjorneContext context) throws ShellException {
   if (words.length > 0) {
     CommandLine command = context.buildCommandLine(words);
     command.setStreams(context.getIOs());
     return shell.invokeAsynchronous(command);
   } else {
     return null;
   }
 }
Ejemplo n.º 2
0
 @Override
 public void execute() throws NameNotFoundException, ShellException, HelpException {
   // The above exceptions are either bugs or configuration errors and should be allowed
   // to propagate so that the shell can diagnose them appropriately.
   String alias;
   CommandLine commandLine = getCommandLine();
   PrintWriter out = getOutput().getPrintWriter();
   PrintWriter err = getError().getPrintWriter();
   if (argAlias.isSet()) {
     alias = argAlias.getValue();
   } else if (commandLine.getCommandName() != null) {
     alias = commandLine.getCommandName();
   } else {
     alias = "help";
   }
   CommandShell shell = null;
   try {
     shell = (CommandShell) ShellUtils.getShellManager().getCurrentShell();
     CommandInfo cmdInfo = shell.getCommandInfo(alias);
     Help cmdHelp = HelpFactory.getHelpFactory().getHelp(alias, cmdInfo);
     if (cmdHelp == null) {
       err.format(err_no_help, alias);
       exit(1);
     }
     cmdHelp.help(out);
     otherAliases(shell.getAliasManager(), alias, cmdInfo.getCommandClass().getName(), out);
   } catch (HelpException ex) {
     err.format(err_help_ex, alias, ex.getLocalizedMessage());
     throw ex;
   } catch (ShellException ex) {
     err.println(ex.getMessage());
     throw ex;
   } catch (SecurityException ex) {
     err.format(err_sec_ex, alias, ex.getLocalizedMessage());
     throw ex;
   }
 }
Ejemplo n.º 3
0
 public CommandShell getShell() throws ShellException {
   CommandShell shell = new TestCommandShell(System.in, System.out, System.err);
   shell.configureShell();
   return shell;
 }