-
Notifications
You must be signed in to change notification settings - Fork 441
Closed
Milestone
Description
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));