You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, if a user wants to show some data (for example environment variables) in tabular format, they need to implement IHelpSectionRenderer and have custom logic that builds a TextTable.
Picocli internally has similar logic to build a TextTable for the exit codes section. It makes sense to expose some of the mechanics for this as public API to reduce custom code in client applications.
Proposed new methods:
Help.createHeading(String, Object...)
Help.createTextTable(Map<?, ?>)
Example usage:
// help section keysstaticfinalStringSECTION_KEY_ENV_HEADING = "environmentVariablesHeading";
staticfinalStringSECTION_KEY_ENV_DETAILS = "environmentVariables";
// ...// the data to displayMap<String, String> env = newLinkedHashMap<>();
env.put("FOO", "explanation of foo");
env.put("BAR", "explanation of bar");
env.put("XYZ", "xxxx yyyy zzz");
// register the custom section renderersCommandLinecmd = newCommandLine(newMyApp());
cmd.getHelpSectionMap().put(SECTION_KEY_ENV_HEADING,
help -> help.createHeading("Environment Variables:%n"));
cmd.getHelpSectionMap().put(SECTION_KEY_ENV_DETAILS,
help -> help.createTextTable(env).toString());
// specify the location of the new sectionsList<String> keys = newArrayList<>(cmd.getHelpSectionKeys());
intindex = keys.indexOf(CommandLine.Model.UsageMessageSpec.SECTION_KEY_FOOTER_HEADING);
keys.add(index, SECTION_KEY_ENV_HEADING);
keys.add(index + 1, SECTION_KEY_ENV_DETAILS);
cmd.setHelpSectionKeys(keys);
The text was updated successfully, but these errors were encountered:
Related: #856
Currently, if a user wants to show some data (for example environment variables) in tabular format, they need to implement
IHelpSectionRenderer
and have custom logic that builds aTextTable
.Picocli internally has similar logic to build a
TextTable
for the exit codes section. It makes sense to expose some of the mechanics for this as public API to reduce custom code in client applications.Proposed new methods:
Help.createHeading(String, Object...)
Help.createTextTable(Map<?, ?>)
Example usage:
The text was updated successfully, but these errors were encountered: