Skip to content

Prompt kind/type mismatch: multiselect accepted on enum flag, then fails at runtime #11

@kjanat

Description

@kjanat

Summary

flag.enum([...]).prompt({ kind: 'multiselect' }) is currently accepted, but it fails at runtime with a ValidationError.

This is confusing because the prompt config is accepted up front, and the failure only appears later during resolution.

Minimal repro

import { command, flag } from '@kjanat/dreamcli';
import { runCommand } from '@kjanat/dreamcli/testkit';

const story = command('story')
  .flag(
    'mood',
    flag
      .enum(['calm', 'chaos', 'legendary'])
      .prompt({ kind: 'multiselect', message: 'Set the mood!' }),
  )
  .action(({ flags, out }) => {
    out.log(String(flags.mood));
  });

const result = await runCommand(story, [], { answers: [['calm']] });
console.log(result);

Actual behavior

  • Exit code: 2
  • Error: ValidationError
  • Message:
Invalid value 'calm' from prompt for flag --mood. Allowed: calm, chaos, legendary
Suggestion: Select one of: calm, chaos, legendary

Expected behavior

One of these should happen instead:

  1. Type-level/config-time rejection for incompatible combinations (e.g. multiselect on scalar flags like enum/string/number/boolean), or
  2. Clear runtime config error before prompting (e.g. "multiselect is only supported for array-valued flags").

Context

Docs already describe multiselect as array-oriented, so this looks like a prompt kind vs flag output-type compatibility gap in validation/typing.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions