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:
@@ -127,11 +127,13 @@ func newCmdReenrich(f *cmdutil.Factory) *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// resolveReenrichIDs turns the selection flags into the set of common
|
// 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.
|
// provided: --id, --linked-banner, --linked-org, or --common-third-party.
|
||||||
// The --tracker-type, --keyword, --state, and --without-description flags
|
// The --tracker-type, --keyword, --state, and --without-description flags
|
||||||
// further narrow the anchor's result, except with --id, where the listed
|
// 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(
|
func resolveReenrichIDs(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
pgClient *pg.Client,
|
pgClient *pg.Client,
|
||||||
@@ -148,10 +150,7 @@ func resolveReenrichIDs(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
if anchors > 1 {
|
||||||
case anchors == 0:
|
|
||||||
return nil, fmt.Errorf("specify exactly one selection anchor: --id, --linked-banner, --linked-org, or --common-third-party")
|
|
||||||
case anchors > 1:
|
|
||||||
return nil, fmt.Errorf("--id, --linked-banner, --linked-org, and --common-third-party are mutually exclusive")
|
return nil, fmt.Errorf("--id, --linked-banner, --linked-org, and --common-third-party are mutually exclusive")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user