// The organization selector for the CLI's own parsers (rename design r2, "Selector scopes and // parser matrix"): --org and --business in one parser's scope, under packages/organization/src/ // selector.mjs. An id outside the organization grammar refuses as resolveOrg does, OrgError // org-invalid with exit 3, but while parsing, so no verb reads stdin, prompts for a key or reads a // business file first. Every other refusal is the parser's own usage error. import { ID_PATTERN } from '../../organization/src/vocabulary.mjs'; import { OrgError } from '../../organization/src/org-registry.mjs'; import { selectorScope } from '../../organization/src/selector.mjs'; // usageError(message) returns the parser's usage error for a missing, flag-shaped, repeated or // conflicting selector. export function orgSelector(usageError) { return selectorScope({ valid: id => ID_PATTERN.test(id), refuse: (kind, why) => { throw kind === 'invalid' ? new OrgError('org-invalid', 'invalid organization id') : usageError(why); }, }); }