Package bear.console

Examples of bear.console.ConsoleCallback


    @Override
    protected  <T extends CommandLineResult<?>> T sendCommandImpl(
        final AbstractConsoleCommand<T> command) {

        final ConsoleCallback userCallback = command.getCallback();

        Preconditions.checkArgument(command instanceof CommandLine<?, ?>);

        checkConnection();

        final int[] exitStatus = {0};

        final TaskResult<?>[] result = {new TaskResult(Result.ERROR)};

        //1. it's also blocking
        //2. add callback
        final GenericUnixRemoteEnvironmentPlugin.SshSession.WithLowLevelSession withSession = new GenericUnixRemoteEnvironmentPlugin.SshSession.WithLowLevelSession(getBear()) {
            @Override
            public void act(final Session session, final Session.Shell shell) throws Exception {
                final Session.Command execSshCommand = session.exec(command.asText());

                final GenericUnixRemoteEnvironmentPlugin.RemoteConsole remoteConsole = (GenericUnixRemoteEnvironmentPlugin.RemoteConsole) new GenericUnixRemoteEnvironmentPlugin.RemoteConsole(session, execSshCommand, new AbstractConsole.Listener() {
                    @Nonnull
                    @Override
                    public ConsoleCallbackResult textAdded(String textAdded, MarkedBuffer buffer) throws Exception {
                        $.logOutput(textAdded);

                        if(printToConsole){
                            System.out.print(textAdded);
                        }else{
                            if(!StringUtils.isBlank(textAdded)){
                                logger.debug("text: {}", textAdded);
                            }
                        }

                        if (Strings.isNullOrEmpty(textAdded)) {
                            return ConsoleCallbackResult.CONTINUE;
                        }

                        final String text = buffer.wholeText();

                        command.append(text);

                        if (userCallback != null) {
                            try {
                                ConsoleCallbackResult progress = userCallback.progress(console, textAdded, buffer.wholeText());
                                switch (progress.type) {
                                    case CONTINUE:
                                        break;
                                    case DONE:
                                        return progress;
View Full Code Here


        String pass = $.var($.bear.sshPassword);
        return println(pass);
    }

    public static ConsoleCallback println(final String s) {
        return new ConsoleCallback() {
            @Override
            @Nonnull
            public ConsoleCallbackResult progress(AbstractConsole.Terminal console, String buffer, String wholeText) {
                if(buffer.contains("password")){
                    console.println(s);
View Full Code Here

            // to make sure there are no old start entries
            resetConsolePath($, consolePath);

            WatchDogRunnable runnable = new WatchDogRunnable($, watchDog, new WatchDogInput(
                consolePath, false, new ConsoleCallback() {
                @Override
                public ConsoleCallbackResult progress(final AbstractConsole.Terminal console, String buffer, String wholeText) {
                    //todo these parts are all common, extract!!
                    if(buffer.contains("app crashed - waiting for file") ||   //nodemon message
                        buffer.contains("throw er; // Unhandled 'error' event")){
View Full Code Here

TOP

Related Classes of bear.console.ConsoleCallback

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.