diff --git a/src/validate.ts b/src/validate.ts index f70d348..c10f355 100644 --- a/src/validate.ts +++ b/src/validate.ts @@ -53,8 +53,8 @@ export function validate(parse: { if (intersection.length === 0) { // the command's exactlyOne may or may not include itself, so we'll use Set to add + de-dupe throw new CLIError(`Exactly one of the following must be provided: ${[ - ...new Set(...flag.exactlyOne || [], flag.name), - ].join(',')}`) + ...new Set(flag.exactlyOne?.map(flag => `--${flag}`)), + ].join(', ')}`) } } diff --git a/test/parse.test.ts b/test/parse.test.ts index 1e58265..148bbd4 100644 --- a/test/parse.test.ts +++ b/test/parse.test.ts @@ -719,11 +719,11 @@ See more help with --help`) expect(() => { parse([], { flags: { - foo: flags.string({exactlyOne: ['bar']}), - bar: flags.string({char: 'b', exactlyOne: ['foo']}), + foo: flags.string({exactlyOne: ['bar', 'foo']}), + bar: flags.string({char: 'b', exactlyOne: ['bar', 'foo']}), }, }) - }).to.throw() + }).to.throw('Exactly one of the following must be provided: --bar, --foo') }) it('throws if multiple are set', () => {