Popularity
2.5
Stable
Activity
5.5
-
88
3
7

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.

  • Jansi

    Jansi is a small java library that allows you to use ANSI escape sequences to format your console output which works even on windows.
  • ASCII Table

    Several implementations of a text table, originally using ASCII and UTF-8 characters for borders.
  • Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.
    Promo coderabbit.ai
    CodeRabbit Logo
  • Text-IO

    A library for creating interactive console applications in Java
  • BuildCLI

    BuildCLI is a command-line interface (CLI) tool for managing and automating common tasks in Java project development.
  • Java ASCII Render

    ASCII renderer in pure java with no external dependencies
  • Jexer

    Advanced console (and Swing) text user interface (TUI) library, with mouse-draggable windows, built-in terminal window manager, and sixel image support. Looks like Turbo Vision.

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

Add another 'CLI' Library

README

jbock-compiler jbock

jbock is a command line parser, which uses the same annotation names as JCommander and picocli. However it does not use reflection. It is an annotation processor that generates a custom parser at compile time.

Quick start

Create an abstract class, or alternatively a Java interface, and add the @Command annotation. In your command class, each abstract method must have no arguments, and be annotated with either @Option, @Parameter or @VarargsParameter.

The multiplicity of options and parameters is determined by their return type. List and Optional are "special".

@Command
abstract class DeleteCommand {

  @Option(names = {"-v", "--verbosity"},
          description = "A named option. The return type reflects optionality.")
  abstract OptionalInt verbosity();

  @Parameter(
          index = 0,
          description = {"A required positional parameter. Return type is non-optional.",
                         "Path is a standard type, so no custom converter is needed."})
  abstract Path path();

  @Parameter(
          index = 1,
          description = "An optional positional parameter.")
  abstract Optional<Path> anotherPath();

  @VarargsParameter(
          description = {"A varargs parameter. There can be only one of these.",
                         "The return type must be List."})
  abstract List<Path> morePaths();

  @Option(names = "--dry-run",
          description = "A nullary option, a.k.a. mode flag. Return type is boolean.")
  abstract boolean dryRun();

  @Option(names = "-h",
          description = "A repeatable option. Return type is List.")
  abstract List<String> headers(); 

  @Option(names = "--charset",
          description = "Named option with a custom converter",
          converter = CharsetConverter.class)
  abstract Optional<Charset> charset();

  // sample converter class
  static class CharsetConverter extends StringConverter<Charset> {
    @Override
    protected Charset convert(String token) { return StandardCharsets.UTF_8; }
  }
}

The generated DeleteCommandParser converts a string array to an instance of DeleteCommand:

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

In addition to parseOrExit, the generated parser has a basic parse method that you can build upon to fine-tune the help and error messages for your users.

Standard types

Some types don't need a custom converter. See JbockAutoTypes.java.

Sample projects