Skip to content

Commit 4a2cfa7

Browse files
committed
(#3700) Update all commands and options
Using a newly created spreadsheet which lists all the command/subcommands/options for Chocolatey CLI, update the ChocolateyTabExpansion.ps1 file to use this "source of truth". This includes adding missing commands/subcommands/options where required. In addition, the new default option for each command is applied, and these will be used elsewhere going forward, i.e. in our documentation, so that we can start to get some consistency. In addition, changes were made to the settings.json file for VSCode, so that known words would not cause "Problems" to be reported when editting the file.
1 parent 8218b61 commit 4a2cfa7

File tree

2 files changed

+76
-40
lines changed

2 files changed

+76
-40
lines changed

.vscode/settings.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,24 @@
22
"[powershell]": {
33
"files.encoding": "utf8bom",
44
},
5-
"markdown.extension.toc.levels": "2..6"
5+
"markdown.extension.toc.levels": "2..6",
6+
"cSpell.words": [
7+
"apikey",
8+
"automaticpackage",
9+
"autouninstaller",
10+
"certpassword",
11+
"checksumtype",
12+
"forcex",
13+
"installertype",
14+
"maintainername",
15+
"maintainerrepo",
16+
"outputdirectory",
17+
"packageversion",
18+
"Pathto",
19+
"powertab",
20+
"silentargs",
21+
"unfound",
22+
"whatif",
23+
"windowsfeatures"
24+
]
625
}

src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1

Lines changed: 56 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -35,35 +35,35 @@ function script:chocoCmdOperations($commands, $command, $filter, $currentArgumen
3535
Where-Object { $_ -like "$filter*" }
3636
}
3737

38-
$script:chocoCommands = @('-?','apikey','cache','config','export','feature','help','info','install','list','new','outdated','pack','pin','push','rule','search','source','template','uninstall','upgrade','-h','--help','--version')
38+
$script:chocoCommands = @('apikey','cache','config','export','feature','help','info','install','license','list','new','outdated','pack','pin','push','rule','search','source','support','template','uninstall','upgrade','--help','--version')
3939

4040
# ensure these all have a space to start, or they will cause issues
41-
$allCommands = " --accept-license --cache-location='' --confirm --debug --execution-timeout='' --force --help -? --ignore-http-cache --limit-output --log-file='' --no-color --no-progress --noop --online --proxy='' --proxy-bypass-list='' --proxy-bypass-on-local --proxy-password='' --proxy-user='' --skip-compatibility-checks --trace --verbose"
41+
$allCommands = " --accept-license --cache-location='' --debug --fail-on-standard-error --force --help --ignore-http-cache --limit-output --log-file='' --no-color --no-progress --noop --online --proxy='' --proxy-bypass-list='' --proxy-bypass-on-local --proxy-password='' --proxy-user='' --skip-compatibility-checks --timeout='' --trace --use-system-powershell --verbose --yes"
4242

4343
$commandOptions = @{
44-
apikey = "--api-key='' --remove --source=''"
44+
apikey = "--api-key='' --source=''"
4545
cache = "--expired"
4646
config = "--name='' --value=''"
47-
export = "--include-version-numbers --output-file-path=''"
47+
export = "--include-version --output-file-path=''"
4848
feature = "--name=''"
49-
info = "--cert='' --certpassword='' --disable-package-repository-optimizations --include-configured-sources --local-only --password='' --prerelease --source='' --user='' --version=''"
50-
install = "--allow-downgrade --allow-empty-checksums --allow-empty-checksums-secure --disable-package-repository-optimizations --download-checksum='' --download-checksum-x64='' --download-checksum-type='' --download-checksum-type-x64='' --exit-when-reboot-detected --force-dependencies --forcex86 --ignore-checksums --ignore-dependencies --ignore-detected-reboot --ignore-package-exit-codes --include-configured-sources --install-arguments='' --not-silent --override-arguments --package-parameters='' --params='' --password='' --pin --pre --prerelease --require-checksums --skip-automation-scripts --source='' --source='windowsfeatures' --stop-on-first-package-failure --use-package-exit-codes --user='' --version='' -whatif -y"
51-
list = "--by-id-only --detailed --exact --id-only --id-starts-with --include-programs --page='' --page-size='' --pre --prerelease --source=''"
52-
new = "--automaticpackage installertype='' --maintainer='' maintainername='' maintainerrepo='' --output-directory='' packageversion='' silentargs='' --template-name='' url='' url64='' --use-built-in-template --version=''"
53-
outdated = "--disable-package-repository-optimizations --ignore-pinned --ignore-unfound --include-configured-sources --password='' --pre --prerelease --source='' --user=''"
49+
info = "--cert='' --certpassword='' --disable-repository-optimizations --include-configured-sources --local-only --password='' --prerelease --source='' --user='' --version=''"
50+
install = "--allow-downgrade --allow-empty-checksums --allow-empty-checksums-secure --apply-args-to-dependencies --apply-package-parameters-to-dependencies --cert='' --certpassword='' --disable-repository-optimizations --download-checksum='' --download-checksum-x64='' --download-checksum-type='' --download-checksum-type-x64='' --exit-when-reboot-detected --force-dependencies --forcex86 --ignore-checksum --ignore-dependencies --ignore-detected-reboot --ignore-package-exit-codes --include-configured-sources --install-arguments='' --not-silent --override-arguments --package-parameters='' --password='' --pin --prerelease --require-checksums --skip-hooks --skip-scripts --source='' --stop-on-first-failure --use-package-exit-codes --user='' --version=''"
51+
license = ""
52+
list = "--by-id-only --by-tag-only --detail --exact --id-only --id-starts-with --include-programs --page='' --page-size='' --prerelease --source='' --version=''"
53+
new = "--automaticpackage --download-checksum='' --download-checksum-x64='' --download-checksum-type='' --maintainer='' --name='' --output-directory='' --template='' --use-built-in-template --version=''"
54+
outdated = "--cert='' --certpassword='' --disable-repository-optimizations --ignore-pinned --ignore-unfound --include-configured-sources --password='' --prerelease --source='' --user=''"
5455
pack = "--output-directory='' --version=''"
5556
pin = "--name='' --version=''"
56-
push = "--api-key='' --source='' --timeout=''"
57+
push = "--api-key='' --source=''"
5758
rule = "--name=''"
58-
search = "--approved-only --by-id-only --detailed --disable-package-repository-optimizations --download-cache-only --exact --id-only --id-starts-with --include-configured-sources --include-programs --not-broken --order-by-popularity --page='' --page-size='' --password='' --pre --prerelease --source='' --user=''"
59-
source = " --allow-self-service --bypass-proxy --name='' --password='' --priority='' --source='' --user=''"
59+
search = "--all-versions --approved-only --by-id-only --by-tag-only --cert='' --certpassword='' --detail --disable-repository-optimizations --download-cache-only --exact --id-only --id-starts-with --include-configured-sources --include-programs --not-broken --order-by-popularity --page='' --page-size='' --password='' --prerelease --source='' --user=''"
60+
source = "--admin-only --allow-self-service --bypass-proxy --cert='' --certpassword='' --name='' --password='' --priority='' --source='' --user=''"
61+
support = ""
6062
template = "--name=''"
61-
uninstall = "--all-versions --exit-when-reboot-detected --fail-on-autouninstaller --force-dependencies --ignore-autouninstaller-failure --ignore-detected-reboot --ignore-package-exit-codes --not-silent --override-arguments --params='' --package-parameters='' --remove-dependencies --skip-automation-scripts --skip-autouninstaller --source='windowsfeatures' --stop-on-first-package-failure --uninstall-arguments='' --use-autouninstaller --use-package-exit-codes --version='' -whatif -y"
62-
upgrade = "--allow-downgrade --allow-empty-checksums --allow-empty-checksums-secure --disable-package-repository-optimizations --download-checksum='' --download-checksum-x64='' --download-checksum-type='' --download-checksum-type-x64='' --except='' --exclude-prerelease --exit-when-reboot-detected --fail-on-not-installed --fail-on-unfound --forcex86 --ignore-checksums --ignore-dependencies --ignore-detected-reboot --ignore-package-exit-codes --ignore-pinned --ignore-remembered-options --include-configured-sources --install-arguments='' --install-if-not-installed --not-silent --override-arguments --package-parameters='' --params='' --password='' --pin --pre --prerelease --require-checksums --skip-automation-scripts --skip-when-not-installed --source='' --source='windowsfeatures' --stop-on-first-package-failure --use-package-exit-codes --use-remembered-options --user='' --version='' -whatif -y"
63+
uninstall = "--all-versions --apply-args-to-dependencies --apply-package-parameters-to-dependencies --exit-when-reboot-detected --fail-on-autouninstaller --force-dependencies --ignore-autouninstaller-failure --ignore-detected-reboot --ignore-package-exit-codes --not-silent --override-arguments --package-parameters='' --skip-autouninstaller --skip-hooks --skip-scripts --source='' --stop-on-first-failure --uninstall-arguments='' --use-autouninstaller --use-package-exit-codes --version=''"
64+
upgrade = "--allow-downgrade --allow-empty-checksums --allow-empty-checksums-secure --apply-args-to-dependencies --apply-package-parameters-to-dependencies --cert='' --certpassword='' --disable-repository-optimizations --download-checksum='' --download-checksum-x64='' --download-checksum-type='' --download-checksum-type-x64='' --except='' --exclude-prerelease --exit-when-reboot-detected --fail-on-not-installed --fail-on-unfound --forcex86 --ignore-checksums --ignore-dependencies --ignore-detected-reboot --ignore-package-exit-codes --ignore-pinned --ignore-remembered-arguments --ignore-unfound --include-configured-sources --install-arguments='' --install-if-not-installed --not-silent --override-arguments --package-parameters='' --password='' --pin --prerelease --require-checksums --skip-hooks --skip-if-not-installed --skip-scripts --source='' --stop-on-first-failure --use-package-exit-codes --use-remembered-arguments --user='' --version=''"
6365
}
6466

65-
$commandOptions['find'] = $commandOptions['search']
66-
6767
$licenseFile = "$env:ChocolateyInstall\license\chocolatey.license.xml"
6868

6969
if (Test-Path $licenseFile) {
@@ -74,17 +74,16 @@ if (Test-Path $licenseFile) {
7474
'optimize'
7575
)
7676

77-
$commandOptions.download = "--append-use-original-location --cert='' --certpassword='' --disable-package-repository-optimizations --download-location='' --ignore-dependencies --ignore-unfound-packages --installed-packages --internalize --internalize-all-urls --outputdirectory='' --password='' --prerelease --recompile --resources-location='' --source='' --user='' --version=''"
78-
$commandOptions.sync = "--id='' --output-directory='' --package-id=''"
79-
$commandOptions.optimize = "--id='' --deflate-nupkg-only"
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=''"
78+
$commandOptions.optimize = "--id='' --reduce-nupkg-only"
8079

8180
# Add pro switches to commands that have additional switches on Pro
82-
$proInstallUpgradeOptions = " --deflate-nupkg-only--deflate-package-size --install-arguments-sensitive='' --install-directory='' --max-download-rate='' --package-parameters-sensitive='' --no-deflate-package-size --skip-download-cache --skip-virus-check --use-download-cache --virus-check --virus-positives-minimum=''"
81+
$proInstallUpgradeOptions = " --install-arguments-sensitive='' --install-directory='' --max-download-bits-per-second='' --no-reduce-package-size --package-parameters-sensitive='' --reason='' --reduce-package-size --reduce-nupkg-only --skip-download-cache --skip-virus-check --use-download-cache --virus-check --virus-positives-minimum=''"
8382

8483
$commandOptions.install += $proInstallUpgradeOptions
84+
$commandOptions.new += " --build-package --pause-on-error --use-original-location"
85+
$commandOptions.pin += " --reason=''"
8586
$commandOptions.upgrade += $proInstallUpgradeOptions + " --exclude-chocolatey-packages-during-upgrade-all --include-chocolatey-packages-during-upgrade-all"
86-
$commandOptions.new += " --build-package --checksum='' --checksum64='' --checksumtype='' --keep-remote --pause-on-error --url='' --url64='' --use-original-location"
87-
$commandOptions.pin += " --note=''"
8887

8988
# Add Business-only commands and options if the license is a Business or Trial license
9089
[xml]$xml = Get-Content -Path $licenseFile -ErrorAction Stop
@@ -95,24 +94,27 @@ if (Test-Path $licenseFile) {
9594
# Add business-only commands
9695
$script:chocoCommands = @(
9796
$script:chocoCommands
98-
'support'
97+
'convert'
9998
'sync'
10099
)
101100

102-
$commandOptions.list += " --audit"
101+
$commandOptions.convert = "--ignore-dependencies --include-all --to-format=''"
102+
$commandOptions.list += " --show-audit"
103+
$commandOptions.new += " --file='' --file64='' --from-programs-and-features --include-architecture-in-name --remove-architecture-from-name --url='' --url64=''"
104+
$commandOptions.push += " --client-code='' --endpoint='' redirect-url='' --skip-cleanup"
105+
$commandOptions.sync = "--id='' --output-directory='' --package-id=''"
103106
$commandOptions.uninstall += " --from-programs-and-features"
104-
$commandOptions.new += " --file='' --file64='' --from-programs-and-features --include-architecture-in-name --remove-architecture-from-name"
105107

106108
# Add --use-self-service to commands that support it
107-
$selfServiceCommands = 'download', 'find', 'info', 'install', 'list', 'optimize', 'outdated', 'pin', 'push', 'search', 'sync', 'uninstall', 'upgrade'
109+
$selfServiceCommands = 'download', 'info', 'install', 'list', 'optimize', 'outdated', 'pin', 'push', 'search', 'sync', 'uninstall', 'upgrade'
108110
foreach ($command in $selfServiceCommands) {
109111
$commandOptions.$command += ' --use-self-service'
110112
}
111113
}
112114
}
113115

114116
foreach ($key in @($commandOptions.Keys)) {
115-
$commandOptions.$key += $allCommands
117+
$commandOptions.$key = ($commandOptions.$key + $allCommands).Trim()
116118
}
117119

118120
# Consistent ordering for commands so the added pro commands aren't weirdly out of order
@@ -167,64 +169,79 @@ function Get-AliasPattern($exe) {
167169
function ChocolateyTabExpansion($lastBlock) {
168170
switch -regex ($lastBlock -replace "^$(Get-AliasPattern choco) ", "") {
169171

172+
# Handles apikey first tab
173+
"^(apikey)\s+(?<subcommand>[^-\s]*)$" {
174+
@('add', 'list', 'remove', '--help') | Where-Object { $_ -like "$($matches['subcommand'])*" }
175+
}
176+
170177
# Handles cache first tab
171178
"^(cache)\s+(?<subcommand>[^-\s]*)$" {
172-
@('list', 'remove', '-?') | Where-Object { $_ -like "$($matches['subcommand'])*" }
179+
@('list', 'remove', '--help') | Where-Object { $_ -like "$($matches['subcommand'])*" }
173180
}
174181

175182
# Handles config first tab
176183
"^(config)\s+(?<subcommand>[^-\s]*)$" {
177-
@('list', 'get', 'set', 'unset', '-?') | Where-Object { $_ -like "$($matches['subcommand'])*" }
184+
@('get', 'list', 'set', 'unset', '--help') | Where-Object { $_ -like "$($matches['subcommand'])*" }
178185
}
179186

180187
# Handles feature first tab
181188
"^(feature)\s+(?<subcommand>[^-\s]*)$" {
182-
@('list', 'get', 'disable', 'enable', '-?') | Where-Object { $_ -like "$($matches['subcommand'])*" }
189+
@('disable', 'enable', 'get', 'list', '--help') | Where-Object { $_ -like "$($matches['subcommand'])*" }
183190
}
184191

185192
# Handles install package names
186193
"^(install)\s+(?<package>[^\.][^-\s]+)$" {
187194
chocoRemotePackages $matches['package']
188195
}
189196

197+
# Handles license first tab
198+
"^(license)\s+(?<subcommand>[^-\s]*)$" {
199+
@('info', '--help') | Where-Object { $_ -like "$($matches['subcommand'])*" }
200+
}
201+
190202
# Handles list first tab
191203
"^(list)\s+(?<subcommand>[^-\s]*)$" {
192-
@('<filter>', '-?') | Where-Object { $_ -like "$($matches['subcommand'])*" }
204+
@('<filter>', '--help') | Where-Object { $_ -like "$($matches['subcommand'])*" }
193205
}
194206

195207
# Handles new first tab
196208
"^(new)\s+(?<subcommand>[^-\s]*)$" {
197-
@('<name>', '-?') | Where-Object { $_ -like "$($matches['subcommand'])*" }
209+
@('<name>', '--help') | Where-Object { $_ -like "$($matches['subcommand'])*" }
198210
}
199211

200212
# Handles pack first tab
201213
"^(pack)\s+(?<subcommand>[^-\s]*)$" {
202-
@('<PathtoNuspec>', '-?') | Where-Object { $_ -like "$($matches['subcommand'])*" }
214+
@('<PathtoNuspec>', '--help') | Where-Object { $_ -like "$($matches['subcommand'])*" }
203215
}
204216

205217
# Handles pin first tab
206218
"^(pin)\s+(?<subcommand>[^-\s]*)$" {
207-
@('list', 'add', 'remove', '-?') | Where-Object { $_ -like "$($matches['subcommand'])*" }
219+
@('add', 'list', 'remove', '--help') | Where-Object { $_ -like "$($matches['subcommand'])*" }
208220
}
209221

210222
# Handles push first tab
211223
"^(push)\s+(?<subcommand>[^-\s]*)$" {
212-
@('<PathtoNupkg>', '-?') | Where-Object { $_ -like "$($matches['subcommand'])*" }
224+
@('<PathtoNupkg>', '--help') | Where-Object { $_ -like "$($matches['subcommand'])*" }
225+
}
226+
227+
# Handles rule first tab
228+
"^(rule)\s+(?<subcommand>[^-\s]*)$" {
229+
@('get', 'list', '--help') | Where-Object { $_ -like "$($matches['subcommand'])*" }
213230
}
214231

215232
# Handles search first tab
216-
"^(search|find)\s+(?<subcommand>[^-\s]*)$" {
217-
@('<filter>', '-?') | Where-Object { $_ -like "$($matches['subcommand'])*" }
233+
"^(search)\s+(?<subcommand>[^-\s]*)$" {
234+
@('<filter>', '--help') | Where-Object { $_ -like "$($matches['subcommand'])*" }
218235
}
219236

220237
# Handles source first tab
221238
"^(source)\s+(?<subcommand>[^-\s]*)$" {
222-
@('list', 'add', 'remove', 'disable', 'enable', '-?') | Where-Object { $_ -like "$($matches['subcommand'])*" }
239+
@('add', 'disable', 'enable', 'list', 'remove', '--help') | Where-Object { $_ -like "$($matches['subcommand'])*" }
223240
}
224241

225242
# Handles template first tab
226243
"^(template)\s+(?<subcommand>[^-\s]*)$" {
227-
@('list', 'info', '-?') | Where-Object { $_ -like "$($matches['subcommand'])*" }
244+
@('info', 'list', '--help') | Where-Object { $_ -like "$($matches['subcommand'])*" }
228245
}
229246

230247
# Handles uninstall package names

0 commit comments

Comments
 (0)