Skip to content

Exit Status section in usage help message  #678

@remkop

Description

@remkop

Provide API that allows applications to add an Exit Status section to the usage help message.

Something like this:

Map<String, String> map = new LinkedHashMap<>();
map.put("0", "Program terminated normally"); 
map.put("1", "Invalid user input"); 

CommandLine cmd = new CommandLine(new MyApp());
cmd.setExitCodeUsageSection("Exit Codes%n", map);

Alternative name: setExitStatusHelp, setExitCodeHelpSection. See other comment.


Alternative for creating a map from strings:

List<String> keyValues = Arrays.asList(
        "0:successful termination", 
        "64:invalid input", 
        "70:internal error");
Map<String, String> result = keyValues.stream()
        .collect(Collectors.toMap(
                s -> s.split(":", 1)[0],
                s -> s.split(":", 1)[1],
                (x, y) -> x,
                LinkedHashMap::new));

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions