Skip to content

Terminal width

h908714124 edited this page Jun 12, 2021 · 14 revisions

By default, a terminal width of 80 columns is assumed. On Linux terminals, this often leaves a lot of empty space on the right side of the screen when the usage information is printed.

If you have a library like jline to determine the actual terminal width, then this information can be passed to the generated parser, to make better use of the available space:

public static void main(String[] args) {
    int width = TerminalBuilder.terminal().getWidth();
    DeleteCommand command = new DeleteCommandParser()
        .parse(args)
        .orElseThrow(notSuccess ->
          StandardErrorHandler.builder(notSuccess)
           .withTerminalWidth(width)
           .build().handle());
}
Clone this wiki locally