Reimplement help formatting.

Review Request #2458 - Created July 10, 2015 and submitted

Information
Benjy Weinberger
pants
4355105...
Reviewers
pants-reviews
stuhood
Using the argparse help formatter was no longer viable: we had
to customize it in so many ways it was easier to simply implement
our own. The new implementation:

- Supports subsystem args.
- Separates help info extraction from rendering, which allows
  more code reuse (and less hackiness) in builddict and bash
  completion generation tasks.
- Is better tested than the old code.
- Uses ANSI colors for readability.
- Sensibly handles recursively-registered options (it displays
  them in basic help on the outermost scope the option was
  registered on, but then only in advanced help in the inner
  scopes that inherited the registration via recursion).

This change also makes the implementations of builddict and bash
completion generation simpler and supportive of subsystem options.

This implementation requires knowledge of what a scope represents
(a task, goal, subsystem etc.) and also of who registered each
option on a scope. Note that these overlap but are not identical.
For example, a recursive global option is registered by the global
registrar on all task scopes.

This makes a lot of options code quite a lot simpler, so I took
the opportunity of this refactoring to simplify even further.
For example, we no longer have separate paths for registering
boolean and non-boolean options.

I also deleted a couple of unimportant builddict tests, which
relied more on incidental behavior than on intended properties
of that code.  It was going to be too much effort to get them
to pass (as TestOptions don't expose necessary methods, and it
would be overkill to add them just to support these trivial tests).

CI passes here: https://travis-ci.org/pantsbuild/pants/builds/70451126

A previous run had one odd test failure which I'm currently investigating.

Benjy Weinberger
Stu Hood
Benjy Weinberger
Benjy Weinberger
Review request changed

Status: Closed (submitted)

Change Summary:

Submitted as 6376bc98b423073f22112e7307852ff472d4b165.

Loading...