You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for interactive prompts that ask users for input when required options are not provided via command-line arguments or environment variables. This serves as an additional fallback layer in the value resolution chain.
Motivation
Many modern CLI tools provide interactive prompts to improve usability, especially for commands with many required options. Instead of failing with a validation error, the CLI can interactively guide the user to provide missing values.
This pattern is well-established in tools like npm init, gh repo create, and frameworks like @effect/cli (which provides Prompt.text, Prompt.confirm, Prompt.select, etc.).
Auto-detection from Zod schema (when no explicit type):
Zod Schema
Auto-detected Type
Prompt Behavior
z.string()
"text"
Text input
z.number() / z.coerce.number()
"text"
Text input with numeric validation
z.boolean()
"confirm"
Confirm (y/N)
z.enum([...])
"select"
Select from choices
z.array(z.enum([...]))
"multiselect"
Multi-select
Inherited from completion metadata:
Completion Type
Prompt Behavior
"file"
File path input (with extensions/matcher filter)
"directory"
Directory path input
Prompt-specific types:
Prompt Type
Prompt Behavior
"password"
Hidden text input
Entry Point
Prompts should be available as a separate module to keep the core lightweight:
import{runMain}from"politty";import{withPrompts}from"politty/prompt";// or integrate via options in runMain/runCommand
Considerations
Non-interactive environments: When stdin is not a TTY (e.g., CI/CD, piped input), prompts should be skipped and normal validation errors should be raised
Separate module: To keep the core dependency-free, prompt functionality could live in politty/prompt with an optional dependency on a terminal input library
Summary
Add support for interactive prompts that ask users for input when required options are not provided via command-line arguments or environment variables. This serves as an additional fallback layer in the value resolution chain.
Motivation
Many modern CLI tools provide interactive prompts to improve usability, especially for commands with many required options. Instead of failing with a validation error, the CLI can interactively guide the user to provide missing values.
This pattern is well-established in tools like
npm init,gh repo create, and frameworks like@effect/cli(which providesPrompt.text,Prompt.confirm,Prompt.select, etc.).Proposed Design
Value Resolution Order
Extend the existing fallback chain:
API
Add a
promptoption to thearg()metadata:Prompt Type Resolution
The prompt type is resolved in the following priority order:
Auto-detection from Zod schema (when no explicit type):
z.string()"text"z.number()/z.coerce.number()"text"z.boolean()"confirm"z.enum([...])"select"z.array(z.enum([...]))"multiselect"Inherited from completion metadata:
"file""directory"Prompt-specific types:
"password"Entry Point
Prompts should be available as a separate module to keep the core lightweight:
Considerations
politty/promptwith an optional dependency on a terminal input libraryRelated