DescriptionMoved printUsage to Info
It became apparent that printUsage wasn't really using a Command, it was
just using its Info so heavily as to imply it wanted to be a method on Info;
and, having moved printUsage to Info, it became clear that options are the
sole preserve of the gnuflag.FlagSet, and should not be mentioned in
Info.Args (because to do so is to assert knowledge about the state of a
shared resource, the FlagSet, without legitimately being able to do so). So,
printUsage is now also responsible for inserting `[options]` into the usage
line, in exactly the same way as it does the section actually describing
those options (ie: it only does so if they exist).
As a side-effect, SuperCommand `[options]` are placed before `<command> ...`
in the usage line for the bare SuperCommand; this is IMO sensible because
we're displaying the options that apply whatever command you select, and
which actually *do* work in that position; ofc, when displaying help for a
particular subcommand, we put the options after the command (and before its
positional arguments). So we get:
usage: juju [options] <command> ...
...and:
usage: juju bootstrap [options]
...each of which accurately captures the possibilities in the appropriate
situation.
This branch also includes slightly heavier testing for SuperCommand's Info,
and small tweaks to ensure consistent output of SuperCommand documentation
as expected by those tests.
https://code.launchpad.net/~fwereade/juju/go-fix-usage/+merge/103443
(do not edit description out of merge proposal)
Patch Set 1 #Patch Set 2 : Moved printUsage to Info #
Total comments: 10
Patch Set 3 : Moved printUsage to Info #
Total comments: 10
Patch Set 4 : Moved printUsage to Info #
Total comments: 5
Patch Set 5 : Moved printUsage to Info #
MessagesTotal messages: 10
|