Make old-style flag scoping conform to the new style rules.

Specifically, a singleton task in a goal must be fully qualified
by the goal name, unless the task has the same name as the goal.

E.g., --ivy-report becomes --resolve-ivy-report.

This only affects a small number of flags, and has to happen
sooner or later anyway.

Reviewed at https://rbcommons.com/s/twitter/r/1146/
Simpler implementation of flag prefix gathering.

The previous implementation detected "leaf scopes", to avoid matching
a prefix of a longer prefix. However this was more trouble than it
was worth, and the same effect can be achieved by simply sorting
the scopes.

Reviewed in https://rbcommons.com/s/twitter/r/1147/