Skip to content

Commit a9a5414

Browse files
committed
Add command variant
1 parent 7df2e57 commit a9a5414

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/Cli/dotnet/IDeprecated.cs

+16-6
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,35 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.CommandLine;
5+
using Microsoft.CodeAnalysis.CSharp.Syntax;
6+
using Microsoft.Deployment.DotNet.Releases;
57
using Microsoft.DotNet.Cli.Utils;
8+
using Microsoft.DotNet.Cli.Utils.Extensions;
69
namespace Microsoft.DotNet.Cli;
710

811
public interface IDeprecated
912
{
10-
public static Dictionary<CliOption, (string messageToShow, Version errorLevel)> DeprecatedOptions { get; } = new()
13+
public static Dictionary<CliOption, (string messageToShow, ReleaseVersion errorLevel)> DeprecatedOptions { get; } = new()
1114
{
12-
{ PackageListCommandParser.DeprecatedOption, ("old versions are old", new Version(10, 0, 100)) }
15+
{ PackageListCommandParser.DeprecatedOption, ("old versions are old", new ReleaseVersion(10, 0, 100)) }
1316
};
1417

15-
public static Dictionary<CliArgument, (string messageToShow, Version errorLevel)> DeprecatedArguments { get; } = new()
18+
public static Dictionary<CliArgument, (string messageToShow, ReleaseVersion errorLevel)> DeprecatedArguments { get; } = new()
1619
{
17-
{ PackageAddCommandParser.CmdPackageArgument, ("argument bad; use option", new Version(10, 0, 100)) }
20+
{ PackageAddCommandParser.CmdPackageArgument, ("argument bad; use option", new ReleaseVersion(10, 0, 100)) }
1821
};
1922

2023
public bool IsDeprecated { get; set; }
2124

22-
public static void WarnIfNecessary(IReporter reporter, string messageToShow, Version errorLevel)
25+
public static void WarnIfNecessary(IReporter reporter, string messageToShow, ReleaseVersion errorLevel)
2326
{
24-
reporter.WriteLine(messageToShow);
27+
if (new ReleaseVersion(Utils.Product.Version) < errorLevel)
28+
{
29+
reporter.WriteLine(messageToShow);
30+
}
31+
else
32+
{
33+
reporter.WriteLine(messageToShow.Yellow());
34+
}
2535
}
2636
}

src/Cli/dotnet/commands/dotnet-package/remove/Program.cs

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.CommandLine;
5+
using Microsoft.Deployment.DotNet.Releases;
56
using Microsoft.DotNet.Cli;
67
using Microsoft.DotNet.Cli.Extensions;
78
using Microsoft.DotNet.Cli.Utils;
@@ -34,6 +35,11 @@ public RemovePackageReferenceCommand(
3435

3536
public override int Execute()
3637
{
38+
if (IsDeprecated)
39+
{
40+
IDeprecated.WarnIfNecessary(Reporter.ConsoleOutReporter, "wrong verb order", new ReleaseVersion(10, 0, 100));
41+
}
42+
3743
var projectFilePath = string.Empty;
3844

3945
if (!File.Exists(_fileOrDirectory))

0 commit comments

Comments
 (0)