Examples of CommandInput


Examples of org.cyclopsgroup.jmxterm.io.CommandInput

            File outputFile = new File( options.getOutput() );
            output = new FileCommandOutput( outputFile );
        }
        try
        {
            CommandInput input;
            if ( options.getInput().equals( CliMainOptions.STDIN ) )
            {
                if ( options.isNonInteractive() )
                {
                    input = new InputStreamCommandInput( System.in );
                }
                else
                {
                    ConsoleReader consoleReader = new ConsoleReader( System.in, System.err );
                    final FileHistory history = new FileHistory(
                        new File(System.getProperty("user.home"), ".jmxterm_history"));
                    consoleReader.setHistory(history);
                    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable()
                    {
                        @Override
                        public void run()
                        {
                            try
                            {
                                history.flush();
                            }
                            catch (IOException e)
                            {
                                System.err.println("Failed to flush command history! " + e);
                            }
                        }
                    }));
                    input = new JlineCommandInput( consoleReader, COMMAND_PROMPT );
                }
            }
            else
            {
                File inputFile = new File( options.getInput() );
                if ( !inputFile.isFile() )
                {
                    throw new FileNotFoundException( "File " + inputFile + " is not a valid file" );
                }
                input = new FileCommandInput( new File( options.getInput() ) );
            }
            try
            {
                CommandCenter commandCenter = new CommandCenter( output, input );
                if ( input instanceof JlineCommandInput )
                {
                    ( (JlineCommandInput) input ).getConsole().addCompleter(new ConsoleCompletor(commandCenter));
                }
                if ( options.getUrl() != null )
                {
                    Map<String, Object> env;
                    if ( options.getUser() != null )
                    {
                        env = new HashMap<String, Object>( 1 );
                        String password = options.getPassword();
                        if ( password == null )
                        {
                            password = input.readMaskedString( "Authentication password: " );
                        }
                        String[] credentials = { options.getUser(), password };
                        env.put( JMXConnector.CREDENTIALS, credentials );
                    }
                    else
                    {
                        env = null;
                    }
                    commandCenter.connect( SyntaxUtils.getUrl( options.getUrl(), commandCenter.getProcessManager() ),
                                           env );
                }
                if ( verboseLevel != null )
                {
                    commandCenter.setVerboseLevel( verboseLevel );
                }
                if ( verboseLevel != VerboseLevel.SILENT )
                {
                    output.printMessage( "Welcome to JMX terminal. Type \"help\" for available commands." );
                }
                String line;
                int exitCode = 0;
                int lineNumber = 0;
                while ( ( line = input.readLine() ) != null )
                {
                    lineNumber++;
                    if ( !commandCenter.execute( line ) && options.isExitOnFailure() )
                    {
                        exitCode = -lineNumber;
                        break;
                    }
                    if ( commandCenter.isClosed() )
                    {
                        break;
                    }
                }
                commandCenter.close();
                return exitCode;
            }
            finally
            {
                input.close();
            }
        }
        finally
        {
            output.close();
View Full Code Here

Examples of org.impalaframework.command.framework.CommandInput

        while (className == null) {

            ClassFindCommand classFindCommand = newClassFindCommand();
            classFindCommand.setClassDirectories(classDirectories);

            CommandInput capturedInput = commandState.capture(classFindCommand);

            if (capturedInput.isGoBack()) {
                // skip the rest of this loop and start again
                continue;
            }

            classFindCommand.execute(commandState);

            List<String> foundClasses = classFindCommand.getFoundClasses();

            if (foundClasses.size() >= 2) {
                AlternativeInputCommand altInputCommand = new AlternativeInputCommand(foundClasses
                        .toArray(new String[foundClasses.size()]));

                CommandInput input = commandState.capture(altInputCommand);
                if (input.isGoBack()) {
                    // start again
                    continue;
                }

                altInputCommand.execute(commandState);
View Full Code Here

Examples of org.impalaframework.command.framework.CommandInput

            if (foundMethods.size() >= 2) {
                AlternativeInputCommand altInputCommand = new AlternativeInputCommand(foundMethods
                        .toArray(new String[foundMethods.size()]));

                CommandInput input = commandState.capture(altInputCommand);
                if (input.isGoBack()) {
                    // start again
                    continue;
                }

                altInputCommand.execute(commandState);
View Full Code Here

Examples of org.impalaframework.command.framework.CommandInput

    while (className == null) {

      ClassFindCommand classFindCommand = newClassFindCommand();
      classFindCommand.setClassDirectories(classDirectories);

      CommandInput capturedInput = commandState.capture(classFindCommand);

      if (capturedInput.isGoBack()) {
        // skip the rest of this loop and start again
        continue;
      }

      classFindCommand.execute(commandState);

      List<String> foundClasses = classFindCommand.getFoundClasses();

      if (foundClasses.size() >= 2) {
        AlternativeInputCommand altInputCommand = new AlternativeInputCommand(foundClasses
            .toArray(new String[foundClasses.size()]));

        CommandInput input = commandState.capture(altInputCommand);
        if (input.isGoBack()) {
          // start again
          continue;
        }

        altInputCommand.execute(commandState);
View Full Code Here

Examples of org.impalaframework.command.framework.CommandInput

      if (foundMethods.size() >= 2) {
        AlternativeInputCommand altInputCommand = new AlternativeInputCommand(foundMethods
            .toArray(new String[foundMethods.size()]));

        CommandInput input = commandState.capture(altInputCommand);
        if (input.isGoBack()) {
          // start again
          continue;
        }

        altInputCommand.execute(commandState);
View Full Code Here

Examples of org.impalaframework.command.framework.CommandInput

        while (className == null) {

            ClassFindCommand classFindCommand = newClassFindCommand();
            classFindCommand.setClassDirectories(classDirectories);

            CommandInput capturedInput = commandState.capture(classFindCommand);

            if (capturedInput.isGoBack()) {
                // skip the rest of this loop and start again
                continue;
            }

            classFindCommand.execute(commandState);

            List<String> foundClasses = classFindCommand.getFoundClasses();

            if (foundClasses.size() >= 2) {
                AlternativeInputCommand altInputCommand = new AlternativeInputCommand(foundClasses
                        .toArray(new String[foundClasses.size()]));

                CommandInput input = commandState.capture(altInputCommand);
                if (input.isGoBack()) {
                    // start again
                    continue;
                }

                altInputCommand.execute(commandState);
View Full Code Here

Examples of org.impalaframework.command.framework.CommandInput

            if (foundMethods.size() >= 2) {
                AlternativeInputCommand altInputCommand = new AlternativeInputCommand(foundMethods
                        .toArray(new String[foundMethods.size()]));

                CommandInput input = commandState.capture(altInputCommand);
                if (input.isGoBack()) {
                    // start again
                    continue;
                }

                altInputCommand.execute(commandState);
View Full Code Here

Examples of org.jnode.shell.io.CommandInput

                    System.arraycopy(holders, 0, tmp, 0, fd + 1);
                    holders = tmp;
                }

                CommandIOHolder stream;
                CommandInput in;
                CommandOutput out;
                switch (redir.getRedirectionType()) {
                    case REDIR_DLESS:
                    case REDIR_DLESSDASH:
                        String here = redir.getHereDocument();
                        if (redir.isHereDocumentExpandable()) {
                            here = dollarBacktickExpand(here).toString();
                        }
                        in = new CommandInput(new StringReader(here));
                        stream = new CommandIOHolder(in, true);
                        break;

                    case REDIR_GREAT:
                        try {
                            File file = new File(redir.getArg().getText());
                            if (isNoClobber() && file.exists()) {
                                throw new ShellException("File already exists");
                            }
                            out = new CommandOutput(new FileOutputStream(file));
                            stream = new CommandIOHolder(out, true);
                        } catch (IOException ex) {
                            throw new ShellException("Cannot open output file", ex);
                        }
                        break;

                    case REDIR_CLOBBER:
                    case REDIR_DGREAT:
                        try {
                            FileOutputStream tmp = new FileOutputStream(redir.getArg().getText(),
                                    redir.getRedirectionType() == REDIR_DGREAT);
                            stream = new CommandIOHolder(new CommandOutput(tmp), true);
                        } catch (IOException ex) {
                            throw new ShellException("Cannot open output file", ex);
                        }
                        break;

                    case REDIR_LESS:
                        try {
                            File file = new File(redir.getArg().getText());
                            in = new CommandInput(new FileInputStream(file));
                            stream = new CommandIOHolder(in, true);
                        } catch (IOException ex) {
                            throw new ShellException("Cannot open input file", ex);
                        }
                        break;
View Full Code Here

Examples of org.jnode.shell.io.CommandInput

            Pipeline pipe = pipes.get(name);
            if (pipe == null) {
                pipe = new Pipeline();
                pipes.put(name, pipe);
            }
            return new CommandInput(pipe.createSink());
        }
    }
View Full Code Here

Examples of org.jnode.shell.io.CommandInput

        CommandIO out = CommandLine.DEFAULT_STDOUT;
        CommandIO err = CommandLine.DEFAULT_STDERR;
        try {
            try {
                if (desc.fromFileName != null) {
                    in = new CommandInput(new FileInputStream(desc.fromFileName.text));
                }
            } catch (IOException ex) {
                throw new ShellInvocationException("cannot open '" +
                        desc.fromFileName.text + "': " + ex.getMessage());
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.