Package org.jboss.aesh.extensions.harlem.console

Examples of org.jboss.aesh.extensions.harlem.console.Harlem


        PrintWriter out = new PrintWriter(System.out);

        final Man man = new Man(exampleConsole);
        //man.addPage(new File("/tmp/README.md"), "test");

        final Harlem harlem = new Harlem(exampleConsole);

        final Less less = new Less(exampleConsole);
        final More more = new More(exampleConsole);

        List<org.jboss.aesh.extensions.choice.console.MultipleChoice> choices = new ArrayList<org.jboss.aesh.extensions.choice.console.MultipleChoice>();
        choices.add(new org.jboss.aesh.extensions.choice.console.MultipleChoice(1,"Do you want foo?"));
        choices.add(new org.jboss.aesh.extensions.choice.console.MultipleChoice(2,"Do you want bar?"));

        final MultipleChoice choice =
                new MultipleChoice(exampleConsole, "choice", choices);

        Completion completer = new Completion() {
            @Override
            public void complete(CompleteOperation co) {
                // very simple completor
                List<String> commands = new ArrayList<String>();
                if(co.getBuffer().equals("fo") || co.getBuffer().equals("foo")) {
                    commands.add("foo");
                    commands.add("foobaa");
                    commands.add("foobar");
                    commands.add("foobaxxxxxx");
                    commands.add("foobbx");
                    commands.add("foobcx");
                    commands.add("foobdx");
                }
                else if(co.getBuffer().equals("fooba")) {
                    commands.add("foobaa");
                    commands.add("foobar");
                    commands.add("foobaxxxxxx");
                }
                else if(co.getBuffer().equals("foobar")) {
                    commands.add("foobar");
                }
                else if(co.getBuffer().equals("bar")) {
                    commands.add("bar/");
                }
                else if(co.getBuffer().equals("h")) {
                    commands.add("help.history");
                    commands.add("help");
                }
                else if(co.getBuffer().equals("help")) {
                    commands.add("help.history");
                    commands.add("help");
                }
                else if(co.getBuffer().equals("help.")) {
                    commands.add("help.history");
                }
                else if(co.getBuffer().equals("deploy")) {
                    commands.add("deploy /home/blabla/foo/bar/alkdfe/en/to/tre");
                }
                 co.setCompletionCandidates(commands);
            }
        };

        exampleConsole.addCompletion(completer);
        exampleConsole.addCompletion(man);
        exampleConsole.addCompletion(less);
        exampleConsole.addCompletion(more);
        exampleConsole.addCompletion(harlem);

        exampleConsole.setPrompt(new Prompt("[test@foo]~> "));
        //exampleConsole.pushToConsole(ANSI.greenText());
        //while ((consoleOutput = exampleConsole.read("[test@foo.bar]~> ")) != null) {
        exampleConsole.setConsoleCallback(new AeshConsoleCallback() {
            @Override
            public int execute(ConsoleOperation consoleOutput) {
                try {
                    String line = consoleOutput.getBuffer();
                    exampleConsole.getShell().out().print("======>\"" + line + "\"\n");

                    if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("exit") ||
                            line.equalsIgnoreCase("reset")) {
                        exampleConsole.stop();
                    }
                    if(line.equals("clear"))
                        exampleConsole.clear();
                    if(line.startsWith("man")) {
                        //exampleConsole.attachProcess(test);
                        //man.setCurrentManPage("test");
                        try {
                            man.setFile("/tmp/test.txt.gz");
                            man.setConsole(exampleConsole);
                            man.setControlOperator(consoleOutput.getControlOperator());
                            //exampleConsole.attachProcess(man);
                        }
                        catch (IllegalArgumentException iae) {
                            exampleConsole.getShell().out().print(iae.getMessage());
                        }
                    }
                    if(line.startsWith("choice")) {

                        //exampleConsole.attachProcess(choice);
                    }
                    if(line.startsWith("harlem")) {
                        //exampleConsole.attachProcess(harlem);
                        harlem.afterAttach();
                    }
                    if(line.trim().startsWith("less")) {
                        //is it getting input from pipe
                        if(exampleConsole.getShell().in().getStdIn().available() > 0) {
                            java.util.Scanner s = new java.util.Scanner(exampleConsole.getShell().in().getStdIn()).useDelimiter("\\A");
View Full Code Here


        PrintWriter out = new PrintWriter(System.out);

        final Man man = new Man(exampleConsole);
        //man.addPage(new File("/tmp/README.md"), "test");

        final Harlem harlem = new Harlem(exampleConsole);

        final Less less = new Less(exampleConsole);
        final More more = new More(exampleConsole);

        List<org.jboss.aesh.extensions.choice.console.MultipleChoice> choices = new ArrayList<org.jboss.aesh.extensions.choice.console.MultipleChoice>();
        choices.add(new org.jboss.aesh.extensions.choice.console.MultipleChoice(1,"Do you want foo?"));
        choices.add(new org.jboss.aesh.extensions.choice.console.MultipleChoice(2,"Do you want bar?"));

        final MultipleChoice choice =
                new MultipleChoice(exampleConsole, "choice", choices);

        Completion completer = new Completion() {
            @Override
            public void complete(CompleteOperation co) {
                // very simple completor
                List<String> commands = new ArrayList<String>();
                if(co.getBuffer().equals("fo") || co.getBuffer().equals("foo")) {
                    commands.add("foo");
                    commands.add("foobaa");
                    commands.add("foobar");
                    commands.add("foobaxxxxxx");
                    commands.add("foobbx");
                    commands.add("foobcx");
                    commands.add("foobdx");
                }
                else if(co.getBuffer().equals("fooba")) {
                    commands.add("foobaa");
                    commands.add("foobar");
                    commands.add("foobaxxxxxx");
                }
                else if(co.getBuffer().equals("foobar")) {
                    commands.add("foobar");
                }
                else if(co.getBuffer().equals("bar")) {
                    commands.add("bar/");
                }
                else if(co.getBuffer().equals("h")) {
                    commands.add("help.history");
                    commands.add("help");
                }
                else if(co.getBuffer().equals("help")) {
                    commands.add("help.history");
                    commands.add("help");
                }
                else if(co.getBuffer().equals("help.")) {
                    commands.add("help.history");
                }
                else if(co.getBuffer().equals("deploy")) {
                    commands.add("deploy /home/blabla/foo/bar/alkdfe/en/to/tre");
                }
                 co.setCompletionCandidates(commands);
            }
        };

        exampleConsole.addCompletion(completer);
        exampleConsole.addCompletion(man);
        exampleConsole.addCompletion(less);
        exampleConsole.addCompletion(more);
        exampleConsole.addCompletion(harlem);

        exampleConsole.setPrompt(new Prompt("[test@foo]~> "));
        //exampleConsole.pushToConsole(ANSI.greenText());
        //while ((consoleOutput = exampleConsole.read("[test@foo.bar]~> ")) != null) {
        exampleConsole.setConsoleCallback(new AeshConsoleCallback() {
            @Override
            public int execute(ConsoleOperation consoleOutput) {
                try {
                    String line = consoleOutput.getBuffer();
                    exampleConsole.getShell().out().print("======>\"" + line + "\"\n");

                    if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("exit") ||
                            line.equalsIgnoreCase("reset")) {
                        exampleConsole.stop();
                    }
                    if(line.equals("clear"))
                        exampleConsole.clear();
                    if(line.startsWith("man")) {
                        //exampleConsole.attachProcess(test);
                        //man.setCurrentManPage("test");
                        try {
                            man.setFile("/tmp/test.txt.gz");
                            man.setConsole(exampleConsole);
                            man.setControlOperator(consoleOutput.getControlOperator());
                            //exampleConsole.attachProcess(man);
                        }
                        catch (IllegalArgumentException iae) {
                            exampleConsole.getShell().out().print(iae.getMessage());
                        }
                    }
                    if(line.startsWith("choice")) {

                        //exampleConsole.attachProcess(choice);
                    }
                    if(line.startsWith("harlem")) {
                        //exampleConsole.attachProcess(harlem);
                        harlem.afterAttach();
                    }
                    if(line.trim().startsWith("less")) {
                        //is it getting input from pipe
                        if(exampleConsole.getShell().in().getStdIn().available() > 0) {
                            java.util.Scanner s = new java.util.Scanner(exampleConsole.getShell().in().getStdIn()).useDelimiter("\\A");
View Full Code Here

        PrintWriter out = new PrintWriter(System.out);

        final Man man = new Man(exampleConsole);
        //man.addPage(new File("/tmp/README.md"), "test");

        final Harlem harlem = new Harlem(exampleConsole);

        final Less less = new Less(exampleConsole);
        final More more = new More(exampleConsole);

        List<org.jboss.aesh.extensions.choice.console.MultipleChoice> choices = new ArrayList<org.jboss.aesh.extensions.choice.console.MultipleChoice>();
        choices.add(new org.jboss.aesh.extensions.choice.console.MultipleChoice(1,"Do you want foo?"));
        choices.add(new org.jboss.aesh.extensions.choice.console.MultipleChoice(2,"Do you want bar?"));

        final MultipleChoice choice =
                new MultipleChoice(exampleConsole, "choice", choices);

        Completion completer = new Completion() {
            @Override
            public void complete(CompleteOperation co) {
                // very simple completor
                List<String> commands = new ArrayList<String>();
                if(co.getBuffer().equals("fo") || co.getBuffer().equals("foo")) {
                    commands.add("foo");
                    commands.add("foobaa");
                    commands.add("foobar");
                    commands.add("foobaxxxxxx");
                    commands.add("foobbx");
                    commands.add("foobcx");
                    commands.add("foobdx");
                }
                else if(co.getBuffer().equals("fooba")) {
                    commands.add("foobaa");
                    commands.add("foobar");
                    commands.add("foobaxxxxxx");
                }
                else if(co.getBuffer().equals("foobar")) {
                    commands.add("foobar");
                }
                else if(co.getBuffer().equals("bar")) {
                    commands.add("bar/");
                }
                else if(co.getBuffer().equals("h")) {
                    commands.add("help.history");
                    commands.add("help");
                }
                else if(co.getBuffer().equals("help")) {
                    commands.add("help.history");
                    commands.add("help");
                }
                else if(co.getBuffer().equals("help.")) {
                    commands.add("help.history");
                }
                else if(co.getBuffer().equals("deploy")) {
                    commands.add("deploy /home/blabla/foo/bar/alkdfe/en/to/tre");
                }
                 co.setCompletionCandidates(commands);
            }
        };

        exampleConsole.addCompletion(completer);
        exampleConsole.addCompletion(man);
        exampleConsole.addCompletion(less);
        exampleConsole.addCompletion(more);
        exampleConsole.addCompletion(harlem);

        exampleConsole.setPrompt(new Prompt("[test@foo]~> "));
        //exampleConsole.pushToConsole(ANSI.greenText());
        //while ((consoleOutput = exampleConsole.read("[test@foo.bar]~> ")) != null) {
        exampleConsole.setConsoleCallback(new ConsoleCallback() {
            @Override
            public int readConsoleOutput(ConsoleOperation consoleOutput) {
                try {
                    String line = consoleOutput.getBuffer();
                    exampleConsole.getShell().out().print("======>\"" + line + "\"\n");

                    if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("exit") ||
                            line.equalsIgnoreCase("reset")) {
                        exampleConsole.stop();
                    }
                    if(line.equals("clear"))
                        exampleConsole.clear();
                    if(line.startsWith("man")) {
                        //exampleConsole.attachProcess(test);
                        //man.setCurrentManPage("test");
                        try {
                            man.setFile("/tmp/test.txt.gz");
                            man.setConsole(exampleConsole);
                            man.setControlOperator(consoleOutput.getControlOperator());
                            exampleConsole.attachProcess(man);
                        }
                        catch (IllegalArgumentException iae) {
                            exampleConsole.getShell().out().print(iae.getMessage());
                        }
                    }
                    if(line.startsWith("choice")) {

                        exampleConsole.attachProcess(choice);
                    }
                    if(line.startsWith("harlem")) {
                        exampleConsole.attachProcess(harlem);
                        harlem.afterAttach();
                    }
                    if(line.trim().startsWith("less")) {
                        //is it getting input from pipe
                        if(exampleConsole.getShell().in().getStdIn().available() > 0) {
                            java.util.Scanner s = new java.util.Scanner(exampleConsole.getShell().in().getStdIn()).useDelimiter("\\A");
View Full Code Here

        PrintWriter out = new PrintWriter(System.out);

        final Man man = new Man(exampleConsole);
        //man.addPage(new File("/tmp/README.md"), "test");

        final Harlem harlem = new Harlem(exampleConsole);

        final Less less = new Less(exampleConsole);
        final More more = new More(exampleConsole);

        List<org.jboss.aesh.extensions.choice.console.MultipleChoice> choices = new ArrayList<org.jboss.aesh.extensions.choice.console.MultipleChoice>();
        choices.add(new org.jboss.aesh.extensions.choice.console.MultipleChoice(1,"Do you want foo?"));
        choices.add(new org.jboss.aesh.extensions.choice.console.MultipleChoice(2,"Do you want bar?"));

        final MultipleChoice choice =
                new MultipleChoice(exampleConsole, "choice", choices);

        Completion completer = new Completion() {
            @Override
            public void complete(CompleteOperation co) {
                // very simple completor
                List<String> commands = new ArrayList<String>();
                if(co.getBuffer().equals("fo") || co.getBuffer().equals("foo")) {
                    commands.add("foo");
                    commands.add("foobaa");
                    commands.add("foobar");
                    commands.add("foobaxxxxxx");
                    commands.add("foobbx");
                    commands.add("foobcx");
                    commands.add("foobdx");
                }
                else if(co.getBuffer().equals("fooba")) {
                    commands.add("foobaa");
                    commands.add("foobar");
                    commands.add("foobaxxxxxx");
                }
                else if(co.getBuffer().equals("foobar")) {
                    commands.add("foobar");
                }
                else if(co.getBuffer().equals("bar")) {
                    commands.add("bar/");
                }
                else if(co.getBuffer().equals("h")) {
                    commands.add("help.history");
                    commands.add("help");
                }
                else if(co.getBuffer().equals("help")) {
                    commands.add("help.history");
                    commands.add("help");
                }
                else if(co.getBuffer().equals("help.")) {
                    commands.add("help.history");
                }
                else if(co.getBuffer().equals("deploy")) {
                    commands.add("deploy /home/blabla/foo/bar/alkdfe/en/to/tre");
                }
                 co.setCompletionCandidates(commands);
            }
        };

        exampleConsole.addCompletion(completer);
        exampleConsole.addCompletion(man);
        exampleConsole.addCompletion(less);
        exampleConsole.addCompletion(more);
        exampleConsole.addCompletion(harlem);

        exampleConsole.setPrompt(new Prompt("[test@foo]~> "));
        //exampleConsole.pushToConsole(ANSI.greenText());
        //while ((consoleOutput = exampleConsole.read("[test@foo.bar]~> ")) != null) {
        exampleConsole.setConsoleCallback(new ConsoleCallback() {
            @Override
            public int readConsoleOutput(ConsoleOperation consoleOutput) throws IOException {

                String line = consoleOutput.getBuffer();
                exampleConsole.out().print("======>\"" + line + "\"\n");

                if (line.equalsIgnoreCase("quit") || line.equalsIgnoreCase("exit") ||
                        line.equalsIgnoreCase("reset")) {
                    exampleConsole.stop();
                }
                if(line.equals("clear"))
                    exampleConsole.clear();
                if(line.startsWith("man")) {
                    //exampleConsole.attachProcess(test);
                    //man.setCurrentManPage("test");
                    try {
                        man.setFile("/tmp/test.txt.gz");
                        man.setConsole(exampleConsole);
                        man.setControlOperator(consoleOutput.getControlOperator());
                        exampleConsole.attachProcess(man);
                    }
                    catch (IllegalArgumentException iae) {
                        exampleConsole.out().print(iae.getMessage());
                    }
                }
                if(line.startsWith("choice")) {

                    exampleConsole.attachProcess(choice);
                }
                if(line.startsWith("harlem")) {
                    exampleConsole.attachProcess(harlem);
                    harlem.afterAttach();
                }
                if(line.trim().startsWith("less")) {
                    //is it getting input from pipe
                    if(exampleConsole.in().getStdIn().available() > 0) {
                        java.util.Scanner s = new java.util.Scanner(exampleConsole.in().getStdIn()).useDelimiter("\\A");
View Full Code Here

TOP

Related Classes of org.jboss.aesh.extensions.harlem.console.Harlem

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.