Skip to content

Commit a951970

Browse files
committed
(#3817) Append download tab completion options
Add comprehensive completion entries for the `choco download` command to TabExpansion and update tests to assert those completions when the licensed/pro features are available. - Extend commandOptions.download with many download-related flags: allow-empty-checksums, allow-empty-checksums-secure, ignore-checksum, ignore-dependencies-from-source, require-checksums, and other existing download switches. This ensures the tab completion engine exposes all pro and non-pro download options. - Add a Pester test case (Should list completions for downolad (Licensed)) that verifies the completion list includes the newly added download switches. The test is skipped when the license flag ($isLicensed) is not set, preserving existing test behavior. This change fixes missing completions for `choco download`, improving the shell UX for licensed users and keeping tests aligned with available pro flags.
1 parent 92d8bf0 commit a951970

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ if (Test-Path $licenseFile) {
7474
'optimize'
7575
)
7676

77-
$commandOptions.download = "--append-use-original-location --cert='' --certpassword='' --disable-repository-optimizations --download-location='' --ignore-dependencies --ignore-unfound --installed-packages --internalize --internalize-all-urls --output-directory='' --password='' --prerelease --resources-location='' --skip-download-cache --skip-virus-check --source='' --use-download-cache --user='' --version='' --virus-check --virus-positives-minimum=''"
77+
$commandOptions.download = "--allow-empty-checksums --allow-empty-checksums-secure --append-use-original-location --cert='' --certpassword='' --disable-repository-optimizations --download-location='' --ignore-checksum --ignore-dependencies --ignore-dependencies-from-source='' --ignore-unfound --installed-packages --internalize --internalize-all-urls --output-directory='' --password='' --prerelease --require-checksums --resources-location='' --skip-download-cache --skip-virus-check --source='' --use-download-cache --user='' --version='' --virus-check --virus-positives-minimum=''"
7878
$commandOptions.optimize = "--id='' --reduce-nupkg-only"
7979

8080
# Add pro switches to commands that have additional switches on Pro

tests/pester-tests/chocolateyProfile.Tests.ps1

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,41 @@ Describe "Chocolatey Profile" -Tag Chocolatey, Profile, Environment {
100100
$Completions | Should -Contain "--value=''" -Because $becauseCompletions
101101
}
102102

103+
It "Should list completions for download (Licensed)" -Skip:(!$isLicensed) {
104+
$Command = "choco download "
105+
$Completions = (TabExpansion2 -inputScript $Command -cursorColumn $Command.Length).CompletionMatches.CompletionText
106+
107+
$becauseCompletions = ($Completions -Join ", ")
108+
109+
$Completions | Should -Contain "--allow-empty-checksums" -Because $becauseCompletions
110+
$Completions | Should -Contain "--allow-empty-checksums-secure" -Because $becauseCompletions
111+
$Completions | Should -Contain "--append-use-original-location" -Because $becauseCompletions
112+
$Completions | Should -Contain "--cert=''" -Because $becauseCompletions
113+
$Completions | Should -Contain "--certpassword=''" -Because $becauseCompletions
114+
$Completions | Should -Contain "--disable-repository-optimizations" -Because $becauseCompletions
115+
$Completions | Should -Contain "--download-location=''" -Because $becauseCompletions
116+
$Completions | Should -Contain "--ignore-checksum" -Because $becauseCompletions
117+
$Completions | Should -Contain "--ignore-dependencies" -Because $becauseCompletions
118+
$Completions | Should -Contain "--ignore-dependencies-from-source=''" -Because $becauseCompletions
119+
$Completions | Should -Contain "--ignore-unfound" -Because $becauseCompletions
120+
$Completions | Should -Contain "--installed-packages" -Because $becauseCompletions
121+
$Completions | Should -Contain "--internalize" -Because $becauseCompletions
122+
$Completions | Should -Contain "--internalize-all-urls" -Because $becauseCompletions
123+
$Completions | Should -Contain "--output-directory=''" -Because $becauseCompletions
124+
$Completions | Should -Contain "--password=''" -Because $becauseCompletions
125+
$Completions | Should -Contain "--prerelease" -Because $becauseCompletions
126+
$Completions | Should -Contain "--require-checksums" -Because $becauseCompletions
127+
$Completions | Should -Contain "--resources-location=''" -Because $becauseCompletions
128+
$Completions | Should -Contain "--skip-download-cache" -Because $becauseCompletions
129+
$Completions | Should -Contain "--skip-virus-check" -Because $becauseCompletions
130+
$Completions | Should -Contain "--source=''" -Because $becauseCompletions
131+
$Completions | Should -Contain "--use-download-cache" -Because $becauseCompletions
132+
$Completions | Should -Contain "--user=''" -Because $becauseCompletions
133+
$Completions | Should -Contain "--version=''" -Because $becauseCompletions
134+
$Completions | Should -Contain "--virus-check" -Because $becauseCompletions
135+
$Completions | Should -Contain "--virus-positives-minimum=''" -Because $becauseCompletions
136+
}
137+
103138
It "Should list completions for export" -Skip:$ExportNotPresent {
104139
$Command = "choco export "
105140
$Completions = (TabExpansion2 -inputScript $Command -cursorColumn $Command.Length).CompletionMatches.CompletionText

0 commit comments

Comments
 (0)