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

Problematic formatting: descriptions containing newlines #430

Closed
bbottema opened this issue Aug 4, 2018 · 11 comments
Closed

Problematic formatting: descriptions containing newlines #430

bbottema opened this issue Aug 4, 2018 · 11 comments
Milestone

Comments

@bbottema
Copy link
Contributor

bbottema commented Aug 4, 2018

When I create a command description, newlines work perfectly when directly triggered with --help:

image

However, when it is shown for a parent command on which --help was triggered and shown in the list under Commands:, it breaks the flow completely (I tried with \n and %n):

image

See that Note 1, 2 and 3? Is there a solution for this?

@bbottema
Copy link
Contributor Author

bbottema commented Aug 4, 2018

Same as with #429:

Also, I couldn't find any documentation on how multiple descriptions are handled by picocli rather than a single one with newlines in it.
I discovered I can replace newlines by having multiple descriptions in the description array, but in the Command: listing then, only the first description from the array is shown, which is not the behavior I'm looking for (I expected all descriptions to be rendered).

remkop added a commit that referenced this issue Aug 4, 2018
…wlines) in the subcommands list descriptions
@remkop
Copy link
Owner

remkop commented Aug 4, 2018

I've pushed a fix for this to master. Can you build the project and try it?

I was in a rush and did not have time to create a unit test yet. Can you provide one (or some code snippets that help me reproduce the original problem)? You can just paste some of the code you used to test in a comment here - would be very helpful!

@bbottema
Copy link
Contributor Author

bbottema commented Aug 5, 2018

Simple Java Mail salutes you; it works. I'll see what I can do about that junit test.

Providing the code I used for this is a little problematic. I'm translating from a Java builder API to an intermediate model which is then translated to a picocli command structure. I'll see if I can provide a simple demo.

@bbottema
Copy link
Contributor Author

bbottema commented Aug 5, 2018

This shows the bug with the current latest version in Maven, which is solved by the change you made:

private static void runTest() {
	CommandSpec rootCmd = createCmd("newlines", "Displays subcommands, one of which contains description newlines");
	
	rootCmd.addSubcommand("subA", createCmd("subA", "regular description for subA"));
	rootCmd.addSubcommand("subB", createCmd("subB", "very,\nspecial,\nChristopher Walken style,\ndescription."));
	rootCmd.addSubcommand("subC", createCmd("subC", "regular description for subC"));
	
	CommandLine.ParseResult pr = new CommandLine(rootCmd).parseArgs("--help");
	CommandLine.printHelpIfRequested(pr.asCommandLineList(), out, err, Ansi.AUTO);
}

private static CommandSpec createCmd(String name, String description) {
	CommandSpec cmd = CommandSpec.create()
			.name(name)
			.mixinStandardHelpOptions(true);
	cmd.usageMessage()
			.description(description);
	return cmd;
}

Speaking of which, is the current GitHub source stable? I tend to give my library users the freedom to upgrade maven dependencies in case some breaking bug or security issue is solved. That's why I prefer relying on maven releases...

@remkop
Copy link
Owner

remkop commented Aug 5, 2018

Thanks for the test!

The master branch is continuously modified. I’ll release a new version that includes this fix in the next few days.

@remkop
Copy link
Owner

remkop commented Aug 5, 2018

FYI: picocli is on maven: https://search.maven.org/#search%7Cga%7C1%7Ca%3A%22picocli%22

@bbottema
Copy link
Contributor Author

bbottema commented Aug 5, 2018

Yeah, was already using that. But since you advocate including the entire file in projects, I thought you might have a stable master or something (or an LTS branch).

@remkop
Copy link
Owner

remkop commented Aug 5, 2018

Good point. I should point to a release tag.

@bbottema
Copy link
Contributor Author

bbottema commented Aug 5, 2018

On a side note, do you know of a terminal in Windows 10 that renders ANSI codes properly? @|bold ...|@ doesn't work at all and @|bold,italic ...|@ gives it a white background with black font.

Currently tried cmd, Powershell and ConEmu.

@remkop remkop added this to the 3.5 milestone Aug 5, 2018
@remkop
Copy link
Owner

remkop commented Aug 5, 2018

Have you tried Cygwin? That looks quite pretty and even shows italic.

@remkop remkop closed this as completed in d02a7e4 Aug 5, 2018
@remkop
Copy link
Owner

remkop commented Aug 7, 2018

picocli 3.5 has been released which includes the fix for this issue.

You may also like the interactive feature to read passwords from the console with echo disabled.

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

2 participants