Skip to content

Implement interactive fallback flows for missing CLI parameters #95

@nick-pape

Description

@nick-pape

Summary

The dev design states: "For some of these, e.g. component, solution name, component name, etc, if they are not specified we will fallback to an interactive flow." Currently, all required parameters (--template, --component-name, --library-name) are strictly required — omitting any causes an error with no interactive recovery.

Requirements

Interactive prompts for missing parameters

When the following parameters are not provided via flags, the CLI should interactively prompt for them:

Parameter Prompt type Notes
--template List selection Show available templates (from list-templates logic), let user pick
--solution-name Text input Prompt for solution name
--component-name Text input Prompt for component display name
--library-name Text input Could auto-derive from solution-name + component-name
--package-manager Choice selection npm / pnpm / yarn

Behavior

  • Interactive mode is the default when running in a TTY
  • When stdin is not a TTY (piped input, CI), missing required params should still error
  • --ci-mode or similar flag should explicitly disable interactive prompts
  • Prompts should have sensible defaults where possible (e.g., derive library-name from component-name)

UX flow (example)

$ spfx create
? Choose a template: (Use arrow keys)
  ❯ webpart-minimal - A minimal SPFx web part
    webpart-react - A React-based SPFx web part
    extension-application-customizer - An application customizer
    ...
? Solution name: my-solution
? Component name: Hello World
? Package manager: (npm)

Implementation notes

  • Consider using inquirer or @inquirer/prompts for interactive prompts
  • TTY detection: process.stdin.isTTY
  • Each prompt should validate input inline (e.g., solution name format)
  • After all prompts, show a summary and confirm before scaffolding

Dependencies

Acceptance criteria

  • Running spfx create with no flags enters interactive mode in a TTY
  • Each missing required parameter is prompted for
  • Providing a flag skips its corresponding prompt
  • Non-TTY environments error on missing required params
  • Input validation occurs inline during prompting
  • User can cancel (Ctrl+C) gracefully at any prompt

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions