pacak / bpaf

Command line parser with applicative interface
337 stars 17 forks source link

make `max_width` of help configurable #340

Closed ysndr closed 6 months ago

ysndr commented 6 months ago

bpaf currently applies column wrapping at a hardcoded width of 100 characters.

This PR aims to make this width configurable via the option parser. Additionally it contributes a fix to the breaking logic where earlier only the current cursor position was used to determine, resulting in the trailing word overflowing the set width of 100.

ysndr commented 6 months ago

Draft, because I mean to add derive support and docs, but I'd like to gather a response to the general approach, before spending more time on it.

pacak commented 6 months ago

I'm not opposed to making it configurable even though I'm curious about the motivation.

Implementation looks about right.

ysndr commented 6 months ago

For once 100 characters might not be universally agreed upon (terminals commonly defaulting to 80, ssh reporting a term width of 80, etc). Proposing to change bpafs default to another opinionated value seemed hypocritical. Additionally, providing a config like this allows to adapt to the reported terminal width as well if so desired by the calling application.

pacak commented 6 months ago

Let me know if you need any help with that change :)

ysndr commented 6 months ago

Alright, derive support is in as well now, and fixed the tests that broke due to including the next word width in the breaking decision.

pacak commented 6 months ago

CI failure is not related to your changes. I guess I need to decide how much effort I'm willing to put into supporting rustc 1.56... Will try to fix it tomorrow-ish.