Reputation: 17905
In Java, I want to make a simple, quick console app that provides a series of menus and takes user input, then calls certain methods and outputs other menus. Basically, I need to create a loop:
menu > user selection > action > menu > ...
Ultimately, I'm using this on top of an integration server using Apache Camel. I have a "quick and dirty" app I use to exercise some of the server routes as a development tool. I don't want to spend a lot of time on something so simple.
There has to be an easy way to do this. Consoles and menus on command lines have been around for decades! There must be a java library out there that does this well. I just haven't found one...
Is there a library out there or some Apache utility, or anything that would make creating super quick, super simple console menus a piece of cake?
With the proper tool, it should take less than 30 minutes to make a menu that functions like
git add -i
That is, I need to make something that functions similar to git Interactive commands, or any other console app, and I want to do so quickly.
EDIT:
The suggestion, below, to use "Cliche" worked pretty well, allowing me to just annotate some methods and have a menu built out of that, automatically. In case it helps someone, I wanted to include some important notes on getting Cliche working:
Add a repo:
<repository>
<id>sonatype-nexus-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
Add dependency:
<dependency>
<groupId>com.googlecode.cliche</groupId>
<artifactId>cliche</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
Upvotes: 8
Views: 6865
Reputation: 173
Take a look at Cliche
It uses @Command
method annotations to rapidly create interactive console-based apps. Its type converters are basic but Camel's own extensive type converters could be configured to be used instead. It also offers extra functionality like listing available commands and convention-driven input abbreviations.
Upvotes: 6