carrier
carrier

Reputation: 33049

Are there good Java libraries that facilitate building interactive shell-style applications?

I need to write a simple shell-style application in Java. It would be nice to use a library that takes care of parsing commands and takes care of things like flags and optional/mandatory parameters...

Something that has built-in TAB completion would be particularly great.

Upvotes: 7

Views: 2373

Answers (4)

Xandro
Xandro

Reputation: 11

Have a look on JBoss Forge (https://docs.jboss.org/author/display/FORGE/Home).

Its a build shell based on Java CDI Plugins and it an be extended by custom plugins. I my case I wrote a GWT Plugin based on Forge (https://github.com/xandrox/forge-gwtplugin).

public class ExamplePlugin implements Plugin {

    @Inject private ShellPrompt prompt;

    @Command("run")
    public void run(PipeOut out, @Option(name="value") final String arg){
        out.println("Executed command with value: " + arg);
    }
}  

Upvotes: 1

Jason Day
Jason Day

Reputation: 8839

I much prefer either JewelCLI or args4j over Apache Commons CLI.

There is a good, if somewhat inflammatory, roundup of several java CLI options parsers here.

Upvotes: 2

Sean McCauliff
Sean McCauliff

Reputation: 1514

You can use JLine for editing and Apache Commons CLI for command line parsing.

Upvotes: 5

Morendil
Morendil

Reputation: 3978

BeanShell ?

Upvotes: 3

Related Questions