Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit Status section in usage help message #678

Closed
remkop opened this issue May 2, 2019 · 0 comments
Closed

Exit Status section in usage help message #678

remkop opened this issue May 2, 2019 · 0 comments

Comments

@remkop
Copy link
Owner

remkop commented May 2, 2019

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));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant