A collection of useful tools if you want to make a command line interface of some sorts.
The console-progressbar is designed to show progress when writing long-running console-applications.
It was designed to be used with consoles that support control-characters (like cmd) or that don't (Eclipse console implementation before Mars (4.5)).
It comes with three flavors:
Works with non-control-character enabled consoles. Uses a completely new line for adding progress-characters instead.
prefix: [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]
##################################################
Your ASCII-progressbar. Uses the same line, requiring ASCII escape characters.
prefix: [########------------------------------------------]
Displays the percentage. Needs ASCII escape characters as well.
prefix: [ 72%]
You may extend the visual representations by implementing new graphical variants.
ConsoleProgressBar bar = ConsoleProgressBar.builder().maxValue((double)list.size()).
controlCharacterSupport(!isForFileOut).build();
int count = 0;
for (String s : list) {
doSomething(s);
bar.updateValue(++count).redraw(System.out);
}
bar.complete().redraw(System.out);
System.out.println("\n");
This is a fluent wrapper over the Apache Commons CLI library.
Cli cli = CliParser
.cliFor(args, "ServerBrowser", "a small tool to help validate some things")
.addArg(Arg.String("server").shortName("s")
.description("the server instance to connect to (http://<ip>.<port>)")
.defaultValue(SERVER).optional())
.addArg(Arg.String("user").shortName("u").description("the user to use when connecting to the server")
.defaultValue(USER).optional())
.addArg(Arg.String("password").shortName("p")
.description("the password used when connecting to the server").defaultValue(PASSWORD)
.optional())
.addFlag(Flag.builder("list").shortName("l")
.description("browses and lists all REST-API methods of this server instance"))
.addMinRequired(1, "list").create();
if (cli.isHelpSet()) {
System.exit(0);
}
String endpointUrl = cli.getArgValue("server");
String user = cli.getArgValue("user");
String password = cli.getArgValue("password");
if (cli.isFlagSet("list")) {
// do something...
}