Allow reenrich without a selection anchor

The reenrich command forced callers to pass exactly one selection
anchor (--id, --linked-banner, --linked-org, or --common-third-party)
before any pattern could be re-described. That made the common case of
re-enriching every catalog row with a blank description impossible
without an artificial anchor.

Drop the anchor-required guard while keeping anchors mutually
exclusive. With no anchor, the filtering flags now select across the
whole catalog, so --without-description re-enriches every pattern that
lacks a description.

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-06-09 19:39:16 +02:00
parent 4e72ad3bea
commit 5415b2d438

View File

@@ -127,11 +127,13 @@ func newCmdReenrich(f *cmdutil.Factory) *cobra.Command {
}
// resolveReenrichIDs turns the selection flags into the set of common
// tracker pattern IDs to re-enrich. Exactly one selection anchor must be
// tracker pattern IDs to re-enrich. At most one selection anchor may be
// provided: --id, --linked-banner, --linked-org, or --common-third-party.
// The --tracker-type, --keyword, --state, and --without-description flags
// further narrow the anchor's result, except with --id, where the listed
// patterns are used verbatim.
// patterns are used verbatim. With no anchor, the filtering flags select
// across the whole catalog (e.g. --without-description re-enriches every
// pattern with a blank description).
func resolveReenrichIDs(
ctx context.Context,
pgClient *pg.Client,
@@ -148,10 +150,7 @@ func resolveReenrichIDs(
}
}
switch {
case anchors == 0:
return nil, fmt.Errorf("specify exactly one selection anchor: --id, --linked-banner, --linked-org, or --common-third-party")
case anchors > 1:
if anchors > 1 {
return nil, fmt.Errorf("--id, --linked-banner, --linked-org, and --common-third-party are mutually exclusive")
}