jcommander icon indicating copy to clipboard operation
jcommander copied to clipboard

Set custom text width for usage

Open ghost opened this issue 9 years ago • 6 comments

Invoking usage() always seems to return/print a string wrapped at 80.

Can we set our own wrapping for this?

ghost avatar Feb 09 '17 10:02 ghost

Hi @theonlygusti,

according to @cbeust if you want to have a custom usage you can write your own.

Especially in easy cases (without @Command sub-objects) that should be quite easy with parsing the existing annotations.

Best,

JS

jeremysolarz avatar Feb 10 '17 07:02 jeremysolarz

@jeremysolarz, your suggestion doesn't fix the problem:

I like that the default usage goes through all defined commands/options/etc. and prints them all.

From what I understand, to incorporate this into my own usage, if I were to write it myself, this would be very difficult, as every time I created a new command, option, etc. I'd have to add it to the usage manually.

I feel like custom-width wrapping shouldn't be very difficult to add as some core functionality and it seems almost a must from a usability perspective.

ghost avatar Feb 11 '17 13:02 ghost

@theonlygusti correct meant @Parameters of course.

jeremysolarz avatar Feb 11 '17 13:02 jeremysolarz

For anyone else who might be running into this, too: The default column width of 79 chars is actually configurable via JCommander.setColumnSize.

tze avatar Mar 16 '17 12:03 tze

Thanks @tze for finding this. Than we can close this ticket.

jeremysolarz avatar Mar 16 '17 14:03 jeremysolarz

Thanks @tze. Here is a new permalink for setColumnSize

perlun avatar Nov 29 '18 07:11 perlun