Index: admin/cli/src/main/java/com/sun/enterprise/admin/cli/MultimodeCommand.java =================================================================== --- admin/cli/src/main/java/com/sun/enterprise/admin/cli/MultimodeCommand.java (revision 54841) +++ admin/cli/src/main/java/com/sun/enterprise/admin/cli/MultimodeCommand.java (working copy) @@ -59,6 +59,9 @@ @Service(name = "multimode") @Scoped(PerLookup.class) public class MultimodeCommand extends CLICommand { + + protected String prompt = "asadmin> "; + @Inject private Habitat habitat; @@ -78,6 +81,25 @@ new LocalStringsImpl(MultimodeCommand.class); /** + * Retrieves the real command that is able to handle the given command. + * + * This may be another local or remote command. However, by default the + * specified command is returned. In case no command was found inside the + * current environment a CommandException is being thrown. This is to ensure + * that this method never returns null. + * + * @param command The command name that was issued by the user + * + * @return A valid local or remote command + * + * @throws CommandException in case no command was found to handle the + * user input + */ + protected CLICommand getCommand(String command) throws CommandException { + return CLICommand.getCommand(habitat, command); + } + + /** * The validate method validates that the type and quantity of * parameters and operands matches the requirements for this * command. The validate method supplies missing options from @@ -173,7 +195,7 @@ programOpts.toEnvironment(env); for (;;) { if (printPrompt) { - System.out.print("asadmin> "); + System.out.print(prompt); System.out.flush(); } if ((line = reader.readLine()) == null) { @@ -222,7 +244,13 @@ habitat.remove( habitat.getInhabitantByType(ProgramOptions.class)); habitat.addComponent("program-options", po); - cmd = CLICommand.getCommand(habitat, command); + cmd = getCommand(command); + if(!cmd.getName().equalsIgnoreCase(command)) { + String[] newArgs = new String[args.length + 1]; + newArgs[0] = cmd.getName(); + System.arraycopy(args, 0, newArgs, 1, args.length); + args = newArgs; + } rc = cmd.execute(args); } catch (CommandValidationException cve) { logger.severe(cve.getMessage());