Skip to content

Commit a16e95f

Browse files
committed
docs(inquirerer): add skipPrompt and optionsFrom to README
- Added skipPrompt?: boolean to BaseQuestion docs with usage examples - Added optionsFrom?: string to BaseQuestion docs (was missing) - Added 'Skipping Prompts' section with code examples and key behaviors
1 parent 681331d commit a16e95f

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

packages/inquirerer/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,10 @@ interface BaseQuestion {
146146
default?: any; // Default value
147147
defaultFrom?: string; // Dynamic default from resolver (e.g., 'git.user.name')
148148
setFrom?: string; // Auto-set value from resolver, bypassing prompt entirely
149+
optionsFrom?: string; // Dynamic options from another answer's value
149150
useDefault?: boolean; // Skip prompt and use default
150151
required?: boolean; // Validation requirement
152+
skipPrompt?: boolean; // Skip prompting entirely (field still in man pages / CLI flags)
151153
validate?: (input: any, answers: any) => boolean | Validation;
152154
sanitize?: (input: any, answers: any) => any;
153155
pattern?: string; // Regex pattern for validation
@@ -156,6 +158,40 @@ interface BaseQuestion {
156158
}
157159
```
158160

161+
#### Skipping Prompts
162+
163+
Use `skipPrompt: true` to skip interactive prompting for a question entirely. The field is omitted from the answers object unless the user explicitly passes it via a CLI flag. This is useful for fields with backend-managed defaults where the CLI should not prompt, but should still allow overrides.
164+
165+
```typescript
166+
const questions: Question[] = [
167+
{
168+
type: 'text',
169+
name: 'username',
170+
message: 'Username',
171+
required: true
172+
},
173+
{
174+
type: 'text',
175+
name: 'status',
176+
message: 'Account status',
177+
skipPrompt: true // Won't prompt, but user can pass --status active
178+
}
179+
];
180+
181+
const result = await prompter.prompt({}, questions);
182+
// { username: 'john' } — status is not included
183+
184+
const result2 = await prompter.prompt({ status: 'active' }, questions);
185+
// { username: 'john', status: 'active' } — CLI flag override works
186+
```
187+
188+
Key behaviors:
189+
- The question still appears in generated man pages
190+
- CLI flag overrides (e.g. `--status active`) still work
191+
- The field is simply left out of the answers if not provided
192+
- Different from `when`: `skipPrompt` is unconditional, while `when` depends on other answers
193+
- Different from `useDefault`: `skipPrompt` does not apply a default value
194+
159195
### Non-Interactive Mode
160196

161197
When running in CI/CD or without a TTY, inquirerer automatically falls back to default values:

0 commit comments

Comments
 (0)