Package org.rhq.enterprise.client.commands

Examples of org.rhq.enterprise.client.commands.ClientCommand


        }
    }

    private static void initCommands() {
        for (Class<ClientCommand> commandClass : ClientCommand.COMMANDS) {
            ClientCommand command;
            try {
                command = commandClass.newInstance();
                commands.put(command.getPromptCommandString(), command);
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
View Full Code Here


    }

    public boolean executePromptCommand(String[] args) throws Exception {
        String cmd = args[0];
        if (commands.containsKey(cmd)) {
            ClientCommand command = commands.get(cmd);

            if (shouldDisplayHelp(args)) {
                outputWriter.println("Usage: " + command.getSyntax());
                outputWriter.println(command.getDetailedHelp());
                return true;
            }

            try {
                boolean response = command.execute(this, args);
                processNotes(outputWriter);
                outputWriter.println("");
                return response;
            } catch (CommandLineParseException e) {
                outputWriter.println(command.getPromptCommandString() + ": " + e.getMessage());
                outputWriter.println("Usage: " + command.getSyntax());
            } catch (ArrayIndexOutOfBoundsException e) {
                outputWriter.println(command.getPromptCommandString()
                    + ": An incorrect number of arguments was specified.");
                outputWriter.println("Usage: " + command.getSyntax());
            }
        } else {
            boolean result = commands.get("exec").execute(this, args);
            if (loggedIn()) {
                this.codeCompletion.setScriptContext(getScriptEngine().getContext());
View Full Code Here

                    System.exit(0);
                }
            }

            if (getUser() != null && getPass() != null) {
                ClientCommand loginCmd = getCommands().get("login");
                List<String> argsList = new ArrayList<String>(6); // 6 args at most
                argsList.add("login");
                argsList.add(getUser());
                argsList.add(getPass());
                String host = getHost();
                int port = getPort();
                String transport = getTransport();
                if (host != null) {
                    argsList.add(host);
                    if (port != 0) {
                        argsList.add(String.valueOf(port));
                        if (transport != null) {
                            argsList.add(transport);
                        }
                    }
                }
                loginCmd.execute(ClientMain.this, argsList.toArray(new String[argsList.size()]));
                if (!loggedIn()) {
                    if (isInteractiveMode()) {
                        return;
                    } else {
                        System.exit(1);
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.client.commands.ClientCommand

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.