Skip to content

Conversation

gep13
Copy link
Member

@gep13 gep13 commented Jun 26, 2025

Description Of Changes

This commit improves the PowerShell Tab Completion for Chocolatey CLI, by including completions for the following commands:

  • apikey
  • config
  • feature
  • pin
  • rule
  • source
  • template

Each of these completions rely on directly calling the equivalent "list£ sub-command for each command (with the exception of one of the pin completions, which also relies on running choco list), which unfortunately can take a second to complete.

As a future enhancement to this functionality, we should look to serializing these completions to disk, so that they can be loaded and shown from there. These files would be updated each time an associated command is executed. For example, when someone runs "choco source add" update the completions file for when doing "choco source remove".

A group of Pester tests have been added to ensure that these completions work as expected.

Motivation and Context

We want to have as good an experience at the command line as possible. By bringing more things into the completions file, we make it easier to do the work that is being done.

Testing

The new Pester tests exercise all the tab completions. If the Test-Kitchen tests complete, we shoud be good.

Operating Systems Testing

  • Windows 11

Change Types Made

  • Bug fix (non-breaking change).
  • Feature / Enhancement (non-breaking change).
  • Breaking change (fix or feature that could cause existing functionality to change).
  • Documentation changes.
  • PowerShell code changes.

Change Checklist

  • Requires a change to the documentation.
  • Documentation has been updated.
  • Tests to cover my changes, have been added.
  • All new and existing tests passed?
  • PowerShell code changes: PowerShell v3 compatibility checked?

Related Issue

Relates to #669

Some additional work is required in order to complete this issue.

@gep13 gep13 requested a review from AdmiringWorm June 26, 2025 12:15
@gep13
Copy link
Member Author

gep13 commented Jun 26, 2025

NOTE: This issue relies on this issue being completed, in order to list out only the local packages that are not pinned. Until that is completed, the associated Pester tests will fail to complete.

Copy link
Member

@AdmiringWorm AdmiringWorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a quick look over it, and just one question came to mind.

@gep13
Copy link
Member Author

gep13 commented Jul 1, 2025

@AdmiringWorm I have made the suggested change, and I have also kicked off a Test-Kitchen build as well.

Once you are happy, I think that this one is ready to be merged.

@gep13
Copy link
Member Author

gep13 commented Jul 1, 2025

@AdmiringWorm I have had to make a slight change here, as there were some failing tests. I am going to run the Test-Kitchen tests again. I am expecting that there will be one failure, until the --ignore-pinned PR is merged.

Copy link
Member

@AdmiringWorm AdmiringWorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to submit the review, here is what I noticed.

@gep13
Copy link
Member Author

gep13 commented Jul 1, 2025

@AdmiringWorm I have updated this PR by rebasing onto the head of the develop branch (fixing some merge conflicts) and I have added a new commit to add the usage of the --include-headers option to all Chocolatey CLI command executions, so that we are explicit about how we are handling the output, which will guard against issues with the current status of the alwaysIncludeHeaders feature.

gep13 added 2 commits July 2, 2025 13:20
This commit improves the PowerShell Tab Completion for Chocolatey CLI,
by including completions for the following commands:

* apikey
* config
* feature
* pin
* rule
* source
* template

Each of these completions rely on directly calling the equivalent
"list£ sub-command for each command (with the exception of one of the
pin completions, which also relies on running choco list), which
unfortunately can take a second to complete.

As a future enhancement to this functionality, we should look to
serializing these completions to disk, so that they can be loaded and
shown from there. These files would be updated each time an associated
command is executed. For example, when someone runs "choco source add"
update the completions file for when doing "choco source remove".

A group of Pester tests have been added to ensure that these
completions work as expected.
To ensure that the tab completion always works, regardless of whether
the alwaysIncludeHeaders feature is enabled or not, explicitly make use
of the --include-headers option on each execution of Chocolatey CLI.
This allows us to control what happens with the output, and knowingly
understand the headers that are output.

In addition, expand some options to use their default option values,
for example:

-r -> --limit-output
-h -> --help
Copy link
Member

@AdmiringWorm AdmiringWorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, had to make a small change to switch away for brackets to parenthesis.

@AdmiringWorm AdmiringWorm enabled auto-merge July 2, 2025 11:27
@AdmiringWorm AdmiringWorm merged commit 79388f8 into chocolatey:develop Jul 2, 2025
4 of 5 checks passed
@AdmiringWorm
Copy link
Member

@gep13 great work on getting these tab completions added 👍

@gep13 gep13 deleted the issue669 branch July 9, 2025 09:58
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.

Expand the ChocolateyTabExpansion.ps1 file with completions for multiple Chocolatey CLI commands
2 participants