Interactive Prompts
dreamcli integrates interactive prompts into the flag resolution chain. Prompts activate only when needed and only in interactive contexts.
Per-Flag Prompts
ts
import { } from '@kjanat/dreamcli';
.().({ : 'input', : 'Name?' });
.()
.({ : 'confirm', : 'Sure?' });
.(['a', 'b'])
.({ : 'select', : 'Pick one' });
.(.()).({
: 'multiselect',
: 'Pick many',
: [{ : 'a' }, { : 'b' }],
});Prompts fire only if the flag wasn't resolved by CLI argv, env var, or config. Defaults apply only after prompts are skipped or unanswered.
For the exact non-interactive rules, cancellation fallthrough, and full precedence chain, see CLI Semantics.
Prompt Types
| Kind | Input | Output |
|---|---|---|
input | Free text | string |
confirm | Yes/No | boolean |
select | Single choice | Enum value |
multiselect | Multiple choices | Array |
Per-Command Interactive Resolver
For conditional prompts that depend on other resolved values:
ts
import { , } from '@kjanat/dreamcli';
('deploy')
.('region', .(['us', 'eu', 'ap']))
.('confirm', .())
.(({ }) => ({
: !. && {
: 'select',
: 'Which region?',
},
: . === 'us' && {
: 'confirm',
: 'Deploy to US prod?',
},
}));The resolver receives partially resolved flags (after CLI/env/config) and returns prompt configs for any remaining values.
Non-Interactive Behavior
When stdin is not a TTY (CI, piped input), prompts are automatically skipped. Required flags that would have prompted instead produce a structured error with an actionable message.
Testing Prompts
ts
import {
,
,
,
} from '@kjanat/dreamcli/testkit';
// Provide answers in order
const = await (, [], {
: ['eu'],
});
// Simulate cancellation
const = await (, [], {
: ([]),
});What's Next?
- Related example: Interactive prompts
- Testing — full test harness documentation
- Flags — flag resolution chain
- CLI Semantics — prompt precedence and non-interactive behavior