Skip to content

Support showing flag aliases in the auto complete output #1088

@khaled4vokalz

Description

@khaled4vokalz

Is your feature request related to a problem? Please describe.

When defining flags with aliases (e.g., noProgress with alias no-progress), the autocomplete completions only include the primary flag name (--noProgress) but not the aliases (--no-progress). This creates an inconsistent user experience where users can see and use flag aliases in --help output, but cannot tab-complete them.

  static flags = {
    noProgress: Flags.boolean({
      aliases: ['no-progress'],
      description: "Don't display any progress indicators",
    }),
  };

Describe the solution you'd like

The autocomplete generators (zsh.js, bash-spaces.js, powershell.js) should iterate over flag.aliases and generate completion entries for each alias, similar to how command aliases are already handled.

In genZshFlagArgumentsBlock (zsh.js), after generating the spec for the main flag, also generate specs for each alias:

  for (const flagName of flagNames) {
    const f = flags[flagName];
    // ... existing flag spec generation ...

    // Add alias completions
    if (f.aliases && Array.isArray(f.aliases)) {
      for (const alias of f.aliases) {
        // Generate completion spec for --${alias}
      }
    }
  }

Describe alternatives you've considered

  1. Extending the autocomplete command
    • Attempted to create a custom autocomplete command that extends the plugin's Create command, but the package exports ("exports": "./lib/index.js") don't expose the internal classes needed for extension.
  2. Post-processing the generated files
    • Could modify the generated completion files after they're created, but this is fragile and would break on plugin updates.

Additional context

  • Command aliases are already supported in autocomplete (iterating over c.aliases)
  • The flag aliases property is available in the flag definition and accessible via f.aliases
  • This would provide consistency between --help output (which shows aliases) and autocomplete behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions