Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
<PackageVersion Include="Microsoft.DotNet.Maestro.Tasks" Version="1.1.0-beta.24415.2" />
<PackageVersion Include="Microsoft.DotNet.XliffTasks" Version="$(MicrosoftDotNetXliffTasksVersion)" />
<PackageVersion Include="Microsoft.DotNet.SignTool" Version="10.0.0-beta.25367.5" />
<PackageVersion Include="Microsoft.Extensions.CommandLineUtils.Sources" Version="3.0.0-preview6.19253.5" />
<PackageVersion Include="Microsoft.Extensions.FileProviders.Abstractions" Version="$(MicrosoftExtensionsFileProvidersAbstractionsPackageVersion)" />
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="$(MicrosoftExtensionsFileSystemGlobbingPackageVersion)" />
<PackageVersion Include="Microsoft.Internal.VisualStudio.Shell.Framework" Version="17.10.40173" />
Expand Down Expand Up @@ -179,7 +178,6 @@
<_allowBuildFromSourcePackage Include="Microsoft.CSharp" />
<_allowBuildFromSourcePackage Include="Microsoft.DotNet.Build.Tasks.Feed" />
<_allowBuildFromSourcePackage Include="Microsoft.DotNet.XliffTasks" />
<_allowBuildFromSourcePackage Include="Microsoft.Extensions.CommandLineUtils.Sources" />
<_allowBuildFromSourcePackage Include="Microsoft.Extensions.FileProviders.Abstractions" />
<_allowBuildFromSourcePackage Include="Microsoft.Extensions.FileSystemGlobbing" />
<_allowBuildFromSourcePackage Include="Microsoft.Web.Xdt" />
Expand Down
4 changes: 0 additions & 4 deletions NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
<add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" />
<add key="dotnet-libraries" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-libraries/nuget/v3/index.json" />
<add key="myget-legacy@Local" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/myget-legacy%40Local/nuget/v3/index.json" />
<add key="nuget-build" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/nuget-build/nuget/v3/index.json" />
<add key="vside" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/msft_consumption%40Local/nuget/v3/index.json" />
</packageSources>
Expand Down Expand Up @@ -90,9 +89,6 @@
<package pattern="vslangproj90" />
<package pattern="vswebsite.interop" />
</packageSource>
<packageSource key="myget-legacy@Local">
<package pattern="Microsoft.Extensions.CommandLineUtils.Sources" />
</packageSource>
<packageSource key="VS">
<package pattern="Microsoft.DevDiv.Validation.TestPlatform.Settings.Tasks" />
</packageSource>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#nullable enable

namespace NuGet.CommandLine.XPlat
namespace NuGet.CommandLine.XPlat.Commands
{
internal static class CommandConstants
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,63 +5,14 @@

using System;
using System.CommandLine;
using System.CommandLine.Help;
using System.Threading.Tasks;
using Microsoft.Extensions.CommandLineUtils;
using NuGet.CommandLine.XPlat.Commands;
using NuGet.Common;

namespace NuGet.CommandLine.XPlat
{
internal class ConfigCommand
{
private static HelpOption HelpOption = new HelpOption()
{
Arity = ArgumentArity.Zero
};

private static Argument<string> SetConfigKeyArgument = new Argument<string>(name: "config-key")
{
Arity = ArgumentArity.ExactlyOne,
Description = Strings.ConfigSetConfigKeyDescription,
};

private static Argument<string> UnsetConfigKeyArgument = new Argument<string>(name: "config-key")
{
Arity = ArgumentArity.ExactlyOne,
Description = Strings.ConfigUnsetConfigKeyDescription,
};

private static Argument<string> ConfigValueArgument = new Argument<string>(name: "config-value")
{
Arity = ArgumentArity.ExactlyOne,
Description = Strings.ConfigSetConfigValueDescription,
};

private static Argument<string> AllOrConfigKeyArgument = new Argument<string>(name: "all-or-config-key")
{
Arity = ArgumentArity.ExactlyOne,
Description = Strings.ConfigGetAllOrConfigKeyDescription
};

private static Option<string> WorkingDirectory = new Option<string>(name: "--working-directory")
{
Arity = ArgumentArity.ZeroOrOne,
Description = Strings.ConfigPathsWorkingDirectoryDescription
};

private static Option<bool> ShowPathOption = new Option<bool>(name: "--show-path")
{
Arity = ArgumentArity.Zero,
Description = Strings.ConfigGetShowPathDescription,
};

private static Option<string> ConfigFileOption = new Option<string>(name: "--configfile")
{
Arity = ArgumentArity.ZeroOrOne,
Description = Strings.Option_ConfigFile,
};

internal static void LogException(Exception e, ILogger log)
{
// Log the error
Expand All @@ -78,18 +29,9 @@ internal static void LogException(Exception e, ILogger log)
log.LogVerbose(e.ToString());
}

internal static void Register(CommandLineApplication app)
{
app.Command("config", configCmd =>
{
configCmd.Description = Strings.Config_Description;
});
}

internal static Command Register(Command app, Func<ILogger> getLogger)
internal static Command Register(Command app, Func<ILoggerWithColor> getLogger)
{
var ConfigCmd = new DocumentedCommand(name: "config", description: Strings.Config_Description, "https://aka.ms/dotnet/nuget/config");
ConfigCmd.Options.Add(HelpOption);

// Options directly under the verb 'config'

Expand Down Expand Up @@ -132,14 +74,19 @@ internal static Command Register(Command app, Func<ILogger> getLogger)

private static void RegisterOptionsForCommandConfigPaths(Command cmd, Func<ILogger> getLogger)
{
cmd.Options.Add(WorkingDirectory);
cmd.Options.Add(HelpOption);
var workingDirectory = new Option<string>(name: "--working-directory")
{
Arity = ArgumentArity.ZeroOrOne,
Description = Strings.ConfigPathsWorkingDirectoryDescription
};

cmd.Options.Add(workingDirectory);
// Create handler delegate handler for cmd
cmd.SetAction((parseResult, cancellationToken) =>
{
var args = new ConfigPathsArgs()
{
WorkingDirectory = parseResult.GetValue(WorkingDirectory),
WorkingDirectory = parseResult.GetValue(workingDirectory),
};

int exitCode = ConfigPathsRunner.Run(args, getLogger);
Expand All @@ -149,19 +96,36 @@ private static void RegisterOptionsForCommandConfigPaths(Command cmd, Func<ILogg

private static void RegisterOptionsForCommandConfigGet(Command cmd, Func<ILogger> getLogger)
{
cmd.Arguments.Add(AllOrConfigKeyArgument);
cmd.Options.Add(WorkingDirectory);
cmd.Options.Add(ShowPathOption);
cmd.Options.Add(HelpOption);
var allOrConfigKeyArgument = new Argument<string>(name: "all-or-config-key")
{
Arity = ArgumentArity.ExactlyOne,
Description = Strings.ConfigGetAllOrConfigKeyDescription
};

var workingDirectory = new Option<string>(name: "--working-directory")
{
Arity = ArgumentArity.ZeroOrOne,
Description = Strings.ConfigPathsWorkingDirectoryDescription
};

var showPathOption = new Option<bool>(name: "--show-path")
{
Arity = ArgumentArity.Zero,
Description = Strings.ConfigGetShowPathDescription,
};

cmd.Arguments.Add(allOrConfigKeyArgument);
cmd.Options.Add(workingDirectory);
cmd.Options.Add(showPathOption);

// Create handler delegate handler for cmd
cmd.SetAction((parseResult, cancellationToken) =>
{
var args = new ConfigGetArgs()
{
AllOrConfigKey = parseResult.GetValue(AllOrConfigKeyArgument),
WorkingDirectory = parseResult.GetValue(WorkingDirectory),
ShowPath = parseResult.GetValue(ShowPathOption),
AllOrConfigKey = parseResult.GetValue(allOrConfigKeyArgument),
WorkingDirectory = parseResult.GetValue(workingDirectory),
ShowPath = parseResult.GetValue(showPathOption),
};

int exitCode = ConfigGetRunner.Run(args, getLogger);
Expand All @@ -171,18 +135,35 @@ private static void RegisterOptionsForCommandConfigGet(Command cmd, Func<ILogger

private static void RegisterOptionsForCommandConfigSet(Command cmd, Func<ILogger> getLogger)
{
cmd.Arguments.Add(SetConfigKeyArgument);
cmd.Arguments.Add(ConfigValueArgument);
cmd.Options.Add(ConfigFileOption);
cmd.Options.Add(HelpOption);
var setConfigKeyArgument = new Argument<string>(name: "config-key")
{
Arity = ArgumentArity.ExactlyOne,
Description = Strings.ConfigSetConfigKeyDescription,
};

var configValueArgument = new Argument<string>(name: "config-value")
{
Arity = ArgumentArity.ExactlyOne,
Description = Strings.ConfigSetConfigValueDescription,
};

var configFileOption = new Option<string>(name: "--configfile")
{
Arity = ArgumentArity.ZeroOrOne,
Description = Strings.Option_ConfigFile,
};

cmd.Arguments.Add(setConfigKeyArgument);
cmd.Arguments.Add(configValueArgument);
cmd.Options.Add(configFileOption);
// Create handler delegate handler for cmd
cmd.SetAction((parseResult, cancellationToken) =>
{
var args = new ConfigSetArgs()
{
ConfigKey = parseResult.GetValue(SetConfigKeyArgument),
ConfigValue = parseResult.GetValue(ConfigValueArgument),
ConfigFile = parseResult.GetValue(ConfigFileOption),
ConfigKey = parseResult.GetValue(setConfigKeyArgument),
ConfigValue = parseResult.GetValue(configValueArgument),
ConfigFile = parseResult.GetValue(configFileOption),
};

int exitCode = ConfigSetRunner.Run(args, getLogger);
Expand All @@ -192,16 +173,27 @@ private static void RegisterOptionsForCommandConfigSet(Command cmd, Func<ILogger

private static void RegisterOptionsForCommandConfigUnset(Command cmd, Func<ILogger> getLogger)
{
cmd.Arguments.Add(UnsetConfigKeyArgument);
cmd.Options.Add(ConfigFileOption);
cmd.Options.Add(HelpOption);
var unsetConfigKeyArgument = new Argument<string>(name: "config-key")
{
Arity = ArgumentArity.ExactlyOne,
Description = Strings.ConfigUnsetConfigKeyDescription,
};

var configFileOption = new Option<string>(name: "--configfile")
{
Arity = ArgumentArity.ZeroOrOne,
Description = Strings.Option_ConfigFile,
};

cmd.Arguments.Add(unsetConfigKeyArgument);
cmd.Options.Add(configFileOption);
// Create handler delegate handler for cmd
cmd.SetAction((parseResult, cancellationToken) =>
{
var args = new ConfigUnsetArgs()
{
ConfigKey = parseResult.GetValue(UnsetConfigKeyArgument),
ConfigFile = parseResult.GetValue(ConfigFileOption),
ConfigKey = parseResult.GetValue(unsetConfigKeyArgument),
ConfigFile = parseResult.GetValue(configFileOption),
};

int exitCode = ConfigUnsetRunner.Run(args, getLogger);
Expand Down
Loading
Loading