Skip to content

Conversation

@pyramation
Copy link
Contributor

feat(inquirerer): add alias support for questions

Summary

Adds the ability to define aliases for CLI questions, allowing users to use short flags like -w instead of --workspace. This enables defining questions like:

{
  name: 'workspace',
  type: 'confirm',
  alias: 'w'  // or alias: ['w', 'ws'] for multiple aliases
}

Changes:

  • Added alias?: string | string[] property to BaseQuestion interface
  • Implemented expandAliases() method that maps alias keys to question names before processing
  • Updated prompt messages to show aliases: (--workspace, -w)
  • Updated man page generation to display aliases in help text

Review & Testing Checklist for Human

  • Verify the alias expansion logic in expandAliases() correctly prioritizes the main name over aliases when both are provided
  • Test that the prompt message formatting looks correct with aliases displayed (single char gets -, multi-char gets --)
  • Verify this doesn't break any existing CLI tools that depend on inquirerer

Recommended Test Plan

  1. Run pnpm test in packages/inquirerer to verify all 131 tests pass
  2. Build the package and test in a consuming project with a question that has an alias defined
  3. Verify both -w and --workspace work when alias: 'w' is set

Notes

  • This is part of a larger task to update pgpm init --createWorkspace to use --workspace with -w alias in the constructive repo (separate PR)
  • The alias key is deleted from the result object after expansion to avoid confusion

Link to Devin run: https://app.devin.ai/sessions/9b39745595e74f3782f1a79ead7a6db0
Requested by: Dan Lynch (@pyramation)

- Add 'alias' property to BaseQuestion interface (string | string[])
- Implement expandAliases method to map alias keys to question names
- Update generatePromptMessage to show aliases in prompt hints
- Update generateManPage to show aliases in help text
- Add comprehensive tests for alias functionality
@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit 8d168cb into main Dec 27, 2025
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants