chocolatey / chocolatey/choco

Improve performance of Chocolatey CLI tab completions

Open
#3,823 1 comment 1 reaction 0 assignees View on GitHub
Enhancement
Dominant language
C#
Stars
11.5k
Forks
961
PR merge metrics
No merged PRs in 30d

Description

### Checklist

- [x] I have verified this is the correct repository for opening this issue.
- [x] I have verified no other issues exist related to my request.

### Is Your Feature Request Related To A Problem? Please describe.

Some Tab Expansions, coming from the `ChocolateyTabExpansion.ps1` file, can be slow to complete.

### Describe The Solution. Why is it needed?

After some discussions with @AdmiringWorm a few ideas were discussed to improve the overall performance of the tab completions. The winnder from those discussions was to cache the information that is needed to in a file to disk, and have the tab completions use this file(s) to populate the completions.

For example, run the `choco config list` command, and save the information to disk. Then when someone does `choco config set --name=`, rather than having to run the `choco config list` command to allow cycling through that information, the information is already availalbe in a file on disk, making the look up much faster.

This approach could be used for almost all of the tab completions, by capturing the information from:

* `choco -h` - to get all available commands
* `choco apikey list`
* `choco config list`
* `choco feature list`
* `choco list`
* `choco list --ignore-pinned`
* `choco pin list`
* `choco rule list`
* `choco source list`
* `choco template list`

On top of capturing this information, we could also look to refresh the information when we "know" that something is changing. For example, when some of the following commands are run:

* `choco source add`
* `choco config set`
* `choco config unset`
* `choco feature enable`
* etc

That would be an "easy" way to keep the information up to date, without having to schedule updating of the files, or by some other mechanism.

The only tab expansion that we would not be able to provide any improvement to with this solution would be the information needed when doing `choco search`. This would be able to be improved once we complete [package indexes](https://github.com/chocolatey/choco/issues/820).

### Additional Context

N/A

### Related Issues

* https://github.com/chocolatey/choco/issues/669

Contributor guide

Open the contributing guide

Research direction

Start with ChocolateyTabExpansion.ps1 and the listed choco commands that provide completion data, then review related issue 669. The work is done when tab completions use cached information for the applicable commands and refresh that information when relevant commands change it; choco search is explicitly out of scope until package indexes are complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
cli, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.