Skip to content

Commit 3fd8c10

Browse files
authored
Merge pull request #2643 from AdmiringWorm/2641-Mark-Chocolatey-shims-chocolatey-cinst-clist-cpush-cuninst-cup-are-deprecated
(#2641) Add deprecation messages for shims
2 parents 49c781f + ff51947 commit 3fd8c10

8 files changed

+79
-28
lines changed

GenerateDocs.ps1

+20-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Copyright © 2017 Chocolatey Software, Inc
1+
#Requires -PSEdition Desktop
2+
# Copyright © 2017 Chocolatey Software, Inc
23
# Copyright © 2011 - 2017 RealDimensions Software, LLC
34
#
45
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -206,7 +207,7 @@ param(
206207
return
207208
}
208209
$commandText = $commandText -creplace '^(.+)(\s+Command\s*)$', "# `$1`$2 (choco $commandName)"
209-
$commandText = $commandText -creplace '^(Usage|Troubleshooting|Examples|Exit Codes|Connecting to Chocolatey.org|See It In Action|Alternative Sources|Resources|Packages.config|Scripting \/ Integration - Best Practices \/ Style Guide)', '## $1'
210+
$commandText = $commandText -creplace '^(DEPRECATION NOTICE|Usage|Troubleshooting|Examples|Exit Codes|Connecting to Chocolatey.org|See It In Action|Alternative Sources|Resources|Packages.config|Scripting \/ Integration - Best Practices \/ Style Guide)', '## $1'
210211
$commandText = $commandText -replace '^(Commands|How To Pass Options)', '## $1'
211212
$commandText = $commandText -replace '^(WebPI|Windows Features|Ruby|Cygwin|Python)\s*$', '### $1'
212213
$commandText = $commandText -replace 'NOTE\:', '> :memo: **NOTE**'
@@ -351,6 +352,23 @@ function Generate-CommandReference($commandName, $order) {
351352

352353
$commandOutput += @("---$lineFeed")
353354
$commandOutput += @("<!-- This file is automatically generated based on output from $($sourceCommands)/Chocolatey$($commandName)Command.cs using $($sourceLocation)GenerateDocs.ps1. Contributions are welcome at the original location(s). If the file is not found, it is not part of the open source edition of Chocolatey or the name of the file is different. --> $lineFeed")
355+
356+
$commandOutput += @(@"
357+
> :memo: **WARNING** SHIM DEPRECATION
358+
>
359+
> In version 1.0.0 of Chocolatey Open Source we have deprecated the following shims/shortcuts:
360+
>
361+
> - `chocolatey` (Alias for `choco`)
362+
> - `cinst` (Shortcut for `choco install`)
363+
> - `cpush` (Shortcut for `choco push`)
364+
> - `cuninst` (Shortcut for `cuninst`)
365+
> - `cup` (Shortcut for `choco upgrade`)
366+
>
367+
> We recommend that any scripts calling these shims be updated to use the full command, as
368+
> these shims will be removed in Chocolatey v2.0.0.
369+
370+
"@)
371+
354372
$commandOutput += $(& $chocoExe $commandName.ToLower() -h -r)
355373
$commandOutput += @("$lineFeed~~~$lineFeed$lineFeed[Command Reference](xref:choco-commands)")
356374
$commandOutput += @("$lineFeed$lineFeed*NOTE:* This documentation has been automatically generated from ``choco $($commandName.ToLower()) -h``. $lineFeed")

nuget/chocolatey/tools/chocolateysetup.psm1

+1
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ param(
314314

315315
$from = "$chocolateyPathOld\bin"
316316
$to = "$chocolateyPath\bin"
317+
# TODO: This exclusion list needs to be updated once shims are removed
317318
$exclude = @("choco.exe", "chocolatey.exe", "cinst.exe", "clist.exe", "cpack.exe", "cpush.exe", "cuninst.exe", "cup.exe", "cver.exe", "RefreshEnv.cmd")
318319
Get-ChildItem -Path $from -recurse -Exclude $exclude |
319320
% {

src/chocolatey/infrastructure.app/commands/ChocolateyHelpCommand.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ public static void display_help_message(Container container = null)
9393
}
9494

9595
"chocolatey".Log().Info(@"This is a listing of all of the different things you can pass to choco.
96+
");
97+
98+
"chocolatey".Log().Warn(ChocolateyLoggers.Important, "DEPRECATION NOTICE");
99+
"chocolatey".Log().Warn(@"
100+
The shims `chocolatey`, `cinst`, `clist`, `cpush`, `cuninst` and `cup` are deprecated.
101+
We recommend updating all scripts to use their full command equivalent as these will be
102+
removed in v2.0.0 of Chocolatey.
96103
");
97104
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Options and Switches");
98105

@@ -160,7 +167,8 @@ Following this guide will ensure your experience is not frustrating
160167
based on choco not receiving things you think you are passing to it.
161168
162169
* For consistency, always use `choco`, not `choco.exe`. Never use
163-
shortcut commands like `cinst` or `cup`.
170+
shortcut commands like `cinst` or `cup` (The shortcuts `cinst`
171+
and `cup` will be removed in v2.0.0).
164172
* Always have the command as the first argument to `choco`. e.g.
165173
`choco install`, where `install` is the command.
166174
* If there is a subcommand, ensure that is the second argument. e.g.

src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs

+9-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ namespace chocolatey.infrastructure.app.commands
2323
using commandline;
2424
using configuration;
2525
using infrastructure.commands;
26-
using infrastructure.configuration;
2726
using logging;
2827
using services;
2928

@@ -238,19 +237,25 @@ public virtual void help_message(ChocolateyConfiguration configuration)
238237
this.Log().Info(ChocolateyLoggers.Important, "Install Command");
239238
this.Log().Info(@"
240239
Installs a package or a list of packages (sometimes specified as a
241-
packages.config). Some may prefer to use `cinst` as a shortcut for
242-
`choco install`.
240+
packages.config).
243241
244242
NOTE: 100% compatible with older chocolatey client (0.9.8.32 and below)
245243
with options and switches. Add `-y` for previous behavior with no
246244
prompt. In most cases you can still pass options and switches with one
247245
dash (`-`). For more details, see the command reference (`choco -?`).
248246
");
249247

248+
"chocolatey".Log().Warn(ChocolateyLoggers.Important, "DEPRECATION NOTICE");
249+
"chocolatey".Log().Warn(@"
250+
Starting in v2.0.0 the shortcut `cinst` will be removed and can not be used
251+
to install packages anymore. We recommend you make sure that you always
252+
use the full command going forward (`choco install`).
253+
");
254+
250255
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Usage");
251256
"chocolatey".Log().Info(@"
252257
choco install <pkg|packages.config> [<pkg2> <pkgN>] [<options/switches>]
253-
cinst <pkg|packages.config> [<pkg2> <pkgN>] [<options/switches>]
258+
cinst <pkg|packages.config> [<pkg2> <pkgN>] [<options/switches>] (DEPRECATED, will be removed in v2.0.0)
254259
255260
NOTE: `all` is a special package keyword that will allow you to install
256261
all packages from a custom feed. Will not work with Chocolatey default

src/chocolatey/infrastructure.app/commands/ChocolateyListCommand.cs

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2017 - 2021 Chocolatey Software, Inc
1+
// Copyright © 2017 - 2021 Chocolatey Software, Inc
22
// Copyright © 2011 - 2017 RealDimensions Software, LLC
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,7 +28,7 @@ namespace chocolatey.infrastructure.app.commands
2828
using services;
2929

3030
[CommandFor("list", "lists remote or local packages")]
31-
[CommandFor("search", "searches remote or local packages (alias for list)")]
31+
[CommandFor("search", "searches remote or local packages")]
3232
[CommandFor("find", "searches remote or local packages (alias for search)")]
3333
public class ChocolateyListCommand : IListCommand<PackageResult>
3434
{
@@ -166,6 +166,16 @@ and switches with one dash (`-`). For more details, see
166166
the command reference (`choco -?`).
167167
");
168168

169+
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Usage");
170+
// TODO: use command name in usage and examples, instead of hard
171+
// coding the names?
172+
"chocolatey".Log().Info(@"
173+
choco find <filter> [<options/switches>]
174+
choco list <filter> [<options/switches>]
175+
choco search <filter> [<options/switches>]
176+
clist <filter> [<options/switches>] (DEPRECATED, will be removed in v2.0.0)
177+
");
178+
169179
if (configuration.CommandName.is_equal_to("list"))
170180
{
171181
"chocolatey".Log().Warn(ChocolateyLoggers.Important, "DEPRECATION NOTICE");
@@ -177,18 +187,12 @@ Starting in v2.0.0 the list command will be made local only and will only
177187
178188
To avoid breakage, change any calls made to remote sources to use `choco search`
179189
or `choco find` instead. These will continue to work as usual.
180-
");
181-
}
182190
183-
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Usage");
184-
// TODO: use command name in usage and examples, instead of hard
185-
// coding the names?
186-
"chocolatey".Log().Info(@"
187-
choco find <filter> [<options/switches>]
188-
choco list <filter> [<options/switches>]
189-
choco search <filter> [<options/switches>]
190-
clist <filter> [<options/switches>]
191+
Starting in v2.0.0 the shortcut `clist` will be removed and can not be used
192+
to list package anymore. We recommend you make sure that you always
193+
use the full command going forward (`choco list`).
191194
");
195+
}
192196

193197
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Examples");
194198
"chocolatey".Log().Info(@"

src/chocolatey/infrastructure.app/commands/ChocolateyPushCommand.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ public virtual void help_message(ChocolateyConfiguration configuration)
114114
this.Log().Info(ChocolateyLoggers.Important, "Push Command");
115115
this.Log().Info(@"
116116
Chocolatey will attempt to push a compiled nupkg to a package feed.
117-
Some may prefer to use `cpush` as a shortcut for `choco push`.
118117
119118
NOTE: 100% compatible with older chocolatey client (0.9.8.32 and below)
120119
with options and switches. In most cases you can still pass options and
@@ -132,12 +131,16 @@ the command reference (`choco -?`).
132131
Default push location is deprecated and will be removed by v2.0.0.
133132
It is recommended to always specify the source you want to push to
134133
using the `--source` argument.
134+
135+
Starting in v2.0.0 the shortcut `cpush` will be removed and can not be used
136+
to push packages anymore. We recommend you make sure that you always
137+
use the full command going forward (`choco push`).
135138
");
136139

137140
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Usage");
138141
"chocolatey".Log().Info(@"
139142
choco push [<path to nupkg>] [<options/switches>]
140-
cpush [<path to nupkg>] [<options/switches>]
143+
cpush [<path to nupkg>] [<options/switches>] (DEPRECATED, will be removed in v2.0.0)
141144
142145
NOTE: If there is more than one nupkg file in the folder, the command
143146
will require specifying the path to the file.

src/chocolatey/infrastructure.app/commands/ChocolateyUninstallCommand.cs

+9-3
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ public virtual void help_message(ChocolateyConfiguration configuration)
154154
{
155155
this.Log().Info(ChocolateyLoggers.Important, "Uninstall Command");
156156
this.Log().Info(@"
157-
Uninstalls a package or a list of packages. Some may prefer to use
158-
`cuninst` as a shortcut for `choco uninstall`.
157+
Uninstalls a package or a list of packages.
159158
160159
NOTE: 100% compatible with older chocolatey client (0.9.8.32 and below)
161160
with options and switches. Add `-y` for previous behavior with no
@@ -204,10 +203,17 @@ and licensed enhancements have the ability to inspect more locations
204203
to determine how to automatically uninstall software.
205204
");
206205

206+
"chocolatey".Log().Warn(ChocolateyLoggers.Important, "DEPRECATION NOTICE");
207+
"chocolatey".Log().Warn(@"
208+
Starting in v2.0.0 the shortcut `cuninst` will be removed and can not be used
209+
to uninstall packages anymore. We recommend you make sure that you always
210+
use the full command going forward (`choco uninstall`).
211+
");
212+
207213
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Usage");
208214
"chocolatey".Log().Info(@"
209215
choco uninstall <pkg|all> [pkg2 pkgN] [options/switches]
210-
cuninst <pkg|all> [pkg2 pkgN] [options/switches]
216+
cuninst <pkg|all> [pkg2 pkgN] [options/switches] (DEPRECATED, will be removed in v2.0.0)
211217
212218
NOTE: `all` is a special package keyword that will allow you to
213219
uninstall all packages.

src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2017 - 2021 Chocolatey Software, Inc
1+
// Copyright © 2017 - 2021 Chocolatey Software, Inc
22
// Copyright © 2011 - 2017 RealDimensions Software, LLC
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -267,8 +267,7 @@ public virtual void help_message(ChocolateyConfiguration configuration)
267267
{
268268
this.Log().Info(ChocolateyLoggers.Important, "Upgrade Command");
269269
this.Log().Info(@"
270-
Upgrades a package or a list of packages. Some may prefer to use `cup`
271-
as a shortcut for `choco upgrade`. If you do not have a package
270+
Upgrades a package or a list of packages. If you do not have a package
272271
installed, upgrade will install it.
273272
274273
NOTE: 100% compatible with older Chocolatey client (0.9.8.x and below)
@@ -277,10 +276,17 @@ prompt. In most cases you can still pass options and switches with one
277276
dash (`-`). For more details, see the command reference (`choco -?`).
278277
");
279278

279+
"chocolatey".Log().Warn(ChocolateyLoggers.Important, "DEPRECATION NOTICE");
280+
"chocolatey".Log().Warn(@"
281+
Starting in v2.0.0 the shortcut `cup` will be removed and can not be used
282+
to upgrade or install packages anymore. We recommend you make sure that you always
283+
use the full command going forward (`choco upgrade`).
284+
");
285+
280286
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Usage");
281287
"chocolatey".Log().Info(@"
282288
choco upgrade <pkg|all> [<pkg2> <pkgN>] [<options/switches>]
283-
cup <pkg|all> [<pkg2> <pkgN>] [<options/switches>]
289+
cup <pkg|all> [<pkg2> <pkgN>] [<options/switches>] (DEPRECATED, will be removed in v2.0.0)
284290
285291
NOTE: `all` is a special package keyword that will allow you to upgrade
286292
all currently installed packages.

0 commit comments

Comments
 (0)