Handle multiple workflows; clean code, flag names
Handle multiple workflows; clean code, flag names

We handled that the latest build might not be the build we want within a
workflow, but did not handle the existence of multiple workflows.

Fixing that, the new filtering logic is much easier to comprehend (IMO).

Changed the command-line flags for sanity, since at least one was
now misnamed.  Kept the old names as aliases for compatibility: no
invocation which previously worked should break with this change.

    -workflow <workflow>       NEW
    -jobname <jobname>         aka -workflow-artifact-build
    -retrieve-count <n>        aka -workflow-depth
    -ignore-later-workflows    NEW

By default, we want the build found for a workflow to be part of the
same workflow invocation as the latest build seen for that workflow,
so that we don't skip back to an older generation.  If instead you
just want "the latest build of that name, in any workflow matching this
name", then use `-ignore-later-workflows`.

Tracing what was happening and where data was used, I've cut down the
number of global variables, and changed URL expansion from `%s`
expansions where I couldn't figure out WTH was happening, to a `${var}`
form of expansion, where the template URLs can now be read and
comprehended.

Cut down on function parameter explosion by introducing a `FilterSet`
type concept, to be passed around, together with the expansion object
for populating URLs.

Added guard against `branch` being explicitly set to empty.

One small golint fix.

nbio/cart