cxxopts icon indicating copy to clipboard operation
cxxopts copied to clipboard

Indentation in help

Open mmanolescu opened this issue 6 years ago • 4 comments

Hello, I am currently using the cxxopts help function to print usage info for all the options of my program. The thing is that I want to write multiple lines for each option and I use and I see that the text gets indented on multiple lines.

Here is an example. This is my code:

options.add_options()
	("a,add", "This is the help for add option\n\te.g. --add 1 2 3 test\n\te.g. --add 4 5 6 test2", cxxopts::value<std::string>(), "NUMBER")
	;
std::cout << options.help();

This is the output: image

I have found a work-around. If i modify //widest allowed description from 76 to a number big enough, say 1000. The output is fine. image

Maybe it will be useful to have a way to print the help string unformatted. Thank you.

mmanolescu avatar Oct 03 '18 11:10 mmanolescu

That doesn't look right. I'll take a look.

What do you mean by "unformatted"?

jarro2783 avatar Nov 05 '18 21:11 jarro2783

I think part of the problem is that I never designed this thinking that users would put their own new lines in the help description. I generally intended the help description to be a simple one or two sentence as assistance, and that further help would go somewhere else.

jarro2783 avatar Nov 11 '18 21:11 jarro2783

#215 was recently merged that allows new lines and does tab expansion. Can you have a look at that and see if it helps?

jarro2783 avatar Feb 14 '21 21:02 jarro2783

There is an example in the old #213.

wgahr123 avatar Feb 17 '21 08:02 wgahr123