Improve handling of -v, -V, --version and --pants-version.

Review Request #3071 - Created Nov. 3, 2015 and submitted

Benjy Weinberger
jsirois, stuhood

All these could be used with no argument to print the version and exit.
However we also had a hack where these could take an argument. Pants code
itself didn't use this argument, it was just there to document the fact
that the setup script and the intellij plugin grepped for pants_version
in pants.ini.

Unfortunately supporting this required some argparse hackery, and I want
to move us off argparse altogether (as it's now just a minor implementation
detail of the options system). It was also pretty confusing to have a flag
that did different things depending on whether it had an argument or not.

So now -v, -V and --version are special-cased outside the options system, just like
the -h, -H and --help flags. And indeed they resemble help requests far more
than they resemble options.

--pants-version is now an untirely unrelated option, that always takes an
argument. Pants uses it to verify that it is running at the required version.
Scripts can grep it out of pants.ini, as before.

Note that this is backwards-incompatible: using --pants-version with no
argument now issues an error instead of printing the version. However
this doesn't seem like a big deal, as it was the least intuitive of the
version-printing flags anyway. Use -v, -V or --version for this.

CI passes:

Manually verified expected behaviors.

Benjy Weinberger
John Sirois
Matt Olsen
Benjy Weinberger
Benjy Weinberger
Benjy Weinberger
Benjy Weinberger
Review request changed

Status: Closed (submitted)

Change Summary:


Stu Hood

Oh boy... the -v -> -z thing is going to be fun. Totally reasonable change though. Thanks!

  1. -z thing?

  2. That was just in a test.
  3. Oh... I guess -v == --verbose died a long time ago. Was scarred yesterday by an ancient script still passing -v