diff --git a/src/parser/validate.ts b/src/parser/validate.ts index 82c80af22..e0fccb6bf 100644 --- a/src/parser/validate.ts +++ b/src/parser/validate.ts @@ -49,8 +49,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/parser/parse.test.ts b/test/parser/parse.test.ts index 5bea4f4cc..590213924 100644 --- a/test/parser/parse.test.ts +++ b/test/parser/parse.test.ts @@ -812,15 +812,15 @@ See more help with --help`) try { await 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']}), }, }) } catch (error: any) { message = error.message } - expect(message).to.equal('Exactly one of the following must be provided: b,a,r') + expect(message).to.equal('Exactly one of the following must be provided: --bar, --foo') }) it('throws if multiple are set', async () => {