dart-lang / core

This repository is home to core Dart packages.
https://pub.dev/publishers/dart.dev
BSD 3-Clause "New" or "Revised" License
15 stars 4 forks source link

Make it easier to decide usage line length late #55

Open natebosch opened 4 years ago

natebosch commented 4 years ago

We allow passing a usageLineLength to ArgParser or CommandRunner in the constructor. In both cases the field is final and is read internally by the usage getter. This means that the wrapping needs to be decided before the arguments are parsed, so parsed arguments can't be used to inform the line length.

The most immediate option I can think of is to change usageLineLength from a final field to a settable field, and then the option that controls wrapping would pass a callback that sets the field on the parser.

munificent commented 4 years ago

I've run into other issues with how eager ArgParser and CommandRunner is about pinning things down. In particular, it is surprisingly hard to gracefully handle help options that only show up when --verbose is passed. At some point, we may want to consider a more just-in-time API for generating help/usage information that takes a few parameters instead of having to bake everything when you create the ArgParser.