args icon indicating copy to clipboard operation
args copied to clipboard

Make it easier to decide usage line length late

Open natebosch opened this issue 5 years ago • 1 comments

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.

natebosch avatar Aug 13 '20 21:08 natebosch

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.

munificent avatar Aug 25 '20 23:08 munificent