Skip to content

Click's completion system has been rewrittenΒ #37

@davidism

Description

@davidism

See pallets/click#1484 and pallets/click#1622. The documentation can be found here for now: https://click.palletsprojects.com/en/8.0.x/shell-completion/. In the new system:

  • Each shell can provide completion is a completely different way if needed.
  • It's possible to register support for other shells.
  • Every core object (command, group, chained group, argument, option, type) provides a shell_complete method that provides completions at that level and can be overridden. Parameters additionally accept a shell_complete function in __init__ to override or extend the type's completion.
  • Values for choice, file, path, and directories are completed. Path support is handled by the shell rather than emulated in Click.
  • Arbitrary metadata can be attached to completions, which shell support could use however it likes in the completion script.

However, Click doesn't provide these features:

  • Built-in PowerShell support. This could be added to Click, but my preference right now is for an extension to provide other shell support.
  • An install command. This is probably out of scope for Click.
  • Shell detection. This is out of scope for Click since it relies on an external dependency. I didn't consider implementing it because the method for loading the completion differs between shells anyway, so it's not any extra work to add the shell to the instruction.

Due to all these changes, the click-completion won't work with the next release of Click. We've talked about merging this project into Click before, but I think we pretty much have what we want in core at this point. One option is to make a release that specifies click<8 in install_requires, then have the next version specify click>=8 and continue to support the parts that Click doesn't provide.

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