Clap: Make `textwrap` an optional dependency

Created on 27 Sep 2017  路  8Comments  路  Source: clap-rs/clap

It would be nice to make the textwrap crate an optional dependency, so that those who don't care that much about the nice formatting wouldn't need to install the transitive closure of the dependencies of textwrap (most notably, libc and winapi).

This would also cut down on the quantity of unsafe used (again, transitively) by the dependent crates, should they choose to opt out of pretty help text wrapping.

help message easy nice to have enhancement 2.x mentored

Most helpful comment

Textwrap 0.9.0 has been released with this change, have fun! :-)

All 8 comments

I'd be fine with this, if someone wants an easy PR.

:+1:

Sure thing, I'll make the PR for this one as well.

Looks like we'll need to discuss this one a bit more. Here's the complete problem scenario:

  • The doc says that with featurewrap_help enabled, it will wrap the text respecting the actual with of the terminal rather than assuming 120 columns. It also says that this feature will build the term_size crate as a dependency.
  • This would make me assume that term_size is not necessary when this feature is disabled. However, textwrap is a non-optional dependency, and it has term_size as a non-optional dependency itself. This means that term_size is always a dependency.
  • Does this mean that textwrap should also make term_size an optional dependency; better yet, a non-dependency? As far as I can tell, that crate does not internally rely on knowing the terminal width; it merely provides a convenience callthrough/adaptor interface for term_size. I think that it is poor code organization to hard depend on a crate that is not used directly, only for the sake of providing a convenience adaptor for it.
  • Consequently, I think I'll have to go to the textwrap crate's author and ask him/her to remove term_size as a dependency before I can continue implementing this PR.

The issue referred above has been resolved lightning fast. 馃憤 Once the next release of textwrap is out, I'll write up the necessary changes as a pull request.

Textwrap 0.9.0 has been released with this change, have fun! :-)

Thanks @mgeisler for being flexible and helping with this!

@kbknapp @mgeisler Thanks for your responsiveness and collaboration!

Happy to help! I want my little crate to be useful in as many scenarios as possible.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

XAMPPRocky picture XAMPPRocky  路  17Comments

casey picture casey  路  25Comments

casey picture casey  路  25Comments

jojva picture jojva  路  18Comments

CAD97 picture CAD97  路  21Comments