Programming language: Java
License: MIT License
Tags: CLI     Projects    
Latest version: v3.4.009

jbock alternatives and similar libraries

Based on the "CLI" category.
Alternatively, view jbock alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of jbock or a related project?

Add another 'CLI' Library


jbock-compiler jbock

jbock is a command line parser, which uses the same annotation names as JCommander and picocli. However it makes no use of reflection whatsoever. It is an annotation processor that generates simple parsing code at compile time. jbock requires Java 11.

Quick start

Create an abstract class, or alternatively a Java interface, and add the @Command annotation. In this class or interface, each abstract method corresponds either to a named option or a positional parameter.

abstract class DeleteCommand {

  /* Path, not Optional<Path>:
   * This positional parameter is required (multiplicity = 1).
  @Parameter(index = 0,
             description = "A positional parameter.")
  abstract Path path();

  /* OptionalInt, not int or Integer:
   * This named option is optional (multiplicity = 0..1).
  @Option(names = {"-v", "--verbosity"},
          description = "A named option.")
  abstract OptionalInt verbosity();

The following two classes will be generated: DeleteCommandParser, DeleteCommand_Impl.

The *Parser class can be used directly in a main method:

public static void main(String[] args) {
    DeleteCommand command = new DeleteCommandParser().parseOrExit(args);
    // ...

In addition to parseOrExit, there is also a basic parse method with no side effects. Please see the wiki for details.

Sample projects