Package org.vaadin.console.Console

Examples of org.vaadin.console.Console.Command


        // Publish the methods in the Console class itself for testing purposes.
        console.addCommandProvider(inspector = new ObjectInspector(console));

        // Add help command
        Command helpCommand = new Console.Command() {
            private static final long serialVersionUID = 2838665604270727844L;

            public String getUsage(Console console, String[] argv) {
                return argv[0] + " <command>";
            }

            public Object execute(Console console, String[] argv)
                    throws Exception {
                if (argv.length == 2) {
                    Command hc = console.getCommand(argv[1]);
                    ArrayList<String> cmdArgv = new ArrayList<String>(Arrays
                            .asList(argv));
                    cmdArgv.remove(0);
                    return "Usage: "
                            + hc.getUsage(console, cmdArgv
                                    .toArray(new String[] {}));
                }
                return listAvailableCommands();
            }
        };

        // Bind the same command with multiple names
        console.addCommand("help", helpCommand);
        console.addCommand("info", helpCommand);
        console.addCommand("man", helpCommand);
        // #

        // # 2
        Command systemCommand = new Command() {
            private static final long serialVersionUID = -5733237166568671987L;

            public Object execute(Console console, String[] argv)
                    throws Exception {
                Process p = Runtime.getRuntime().exec(argv);
View Full Code Here

TOP

Related Classes of org.vaadin.console.Console.Command

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.