Skip to content

[RFC] Automate the creation of shell completions #5557

@donovanglover

Description

@donovanglover

I noticed that some options like crystal spec --verbose are missing from the shell completions. To prevent missing completions like this from happening, I believe that some form of automation should be in place. One solution would be to extend OptionParser to handle shell completions as well.

Advantages

  • Less barriers to entry. Knowledge of how to write completions for a specific shell (bash, zsh, etc.) is not needed. Everything is automated and leaves no room for error.
  • Easily verifiable. It is easy to verify that all possible options are accounted for.
  • Don't repeat yourself. You only have to change one location (the source file) to update both the program and its shell completions.

Disadvantages

  • Complexity. Any form of file generation adds complexity to the build process.
  • Scope. Some edge cases or other wanted features may be nontrivial to implement.
  • Delegation of responsibility. OptionParser now handles shell completions as well.

It may also be ideal to create a command similar to crystal docs, but for shell completions instead.

Any other solutions are also appreciated. The goal of this RFC is to prevent having to write the same thing multiple times and ensure that all possible shell completions exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions