restore loc strings, subcommand parsers into separate files
This commit is contained in:
parent
43c13f2f53
commit
daac945742
16 changed files with 269 additions and 175 deletions
|
@ -158,8 +158,8 @@ namespace Microsoft.DotNet.Tools
|
||||||
/// sln
|
/// sln
|
||||||
public const string ArgumentsProjectDescription = "The project file to operate on. If a file is not specified, the command will search the current directory for one.";
|
public const string ArgumentsProjectDescription = "The project file to operate on. If a file is not specified, the command will search the current directory for one.";
|
||||||
public const string ArgumentsSolutionDescription = "Solution file to operate on. If not specified, the command will search the current directory for one.";
|
public const string ArgumentsSolutionDescription = "Solution file to operate on. If not specified, the command will search the current directory for one.";
|
||||||
public const string CmdSlnFile = "<SLN_FILE>";
|
public const string CmdSlnFile = "SLN_FILE";
|
||||||
public const string CmdProjectFile = "<PROJECT>";
|
public const string CmdProjectFile = "PROJECT";
|
||||||
|
|
||||||
/// commands
|
/// commands
|
||||||
public const string CmdFramework = "FRAMEWORK";
|
public const string CmdFramework = "FRAMEWORK";
|
||||||
|
|
|
@ -2,13 +2,10 @@
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
|
||||||
using System.Threading;
|
|
||||||
using Microsoft.DotNet.Cli.CommandLine;
|
using Microsoft.DotNet.Cli.CommandLine;
|
||||||
using Newtonsoft.Json.Linq;
|
using Microsoft.DotNet.Tools;
|
||||||
using LocalizableStrings = Microsoft.DotNet.Tools.Add.PackageReference.LocalizableStrings;
|
using LocalizableStrings = Microsoft.DotNet.Tools.Add.LocalizableStrings;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli
|
namespace Microsoft.DotNet.Cli
|
||||||
{
|
{
|
||||||
|
@ -17,81 +14,12 @@ namespace Microsoft.DotNet.Cli
|
||||||
public static Command Add() =>
|
public static Command Add() =>
|
||||||
Create.Command(
|
Create.Command(
|
||||||
"add",
|
"add",
|
||||||
".NET Add Command",
|
LocalizableStrings.NetAddCommand,
|
||||||
Accept.ExactlyOneArgument()
|
Accept.ExactlyOneArgument()
|
||||||
.DefaultToCurrentDirectory()
|
.DefaultToCurrentDirectory()
|
||||||
.With(name: "PROJECT",
|
.With(name: CommonLocalizableStrings.CmdProjectFile,
|
||||||
description: "The project file to operate on. If a file is not specified, the command will search the current directory for one."),
|
description: CommonLocalizableStrings.ArgumentsProjectDescription), AddPackageParser.AddPackage(),
|
||||||
Create.Command(
|
AddProjectToProjectReferenceParser.AddProjectReference(),
|
||||||
"package",
|
|
||||||
".NET Add Package reference Command",
|
|
||||||
Accept.ExactlyOneArgument(errorMessage: o => LocalizableStrings.SpecifyExactlyOnePackageReference)
|
|
||||||
.WithSuggestionsFrom(QueryNuGet)
|
|
||||||
.With(name: "PACKAGE_NAME",
|
|
||||||
description: "Package references to add"),
|
|
||||||
CommonOptions.HelpOption(),
|
|
||||||
Create.Option("-v|--version",
|
|
||||||
"Version for the package to be added.",
|
|
||||||
Accept.ExactlyOneArgument()
|
|
||||||
.With(name: "VERSION")
|
|
||||||
.ForwardAsSingle(o => $"--version {o.Arguments.Single()}")),
|
|
||||||
Create.Option("-f|--framework",
|
|
||||||
LocalizableStrings.CmdFrameworkDescription,
|
|
||||||
Accept.ExactlyOneArgument()
|
|
||||||
.With(name: "FRAMEWORK")
|
|
||||||
.ForwardAsSingle(o => $"--framework {o.Arguments.Single()}")),
|
|
||||||
Create.Option("-n|--no-restore ",
|
|
||||||
"Add reference without performing restore preview and compatibility check."),
|
|
||||||
Create.Option("-s|--source",
|
|
||||||
"Use specific NuGet package sources to use during the restore.",
|
|
||||||
Accept.ExactlyOneArgument()
|
|
||||||
.With(name: "SOURCE")
|
|
||||||
.ForwardAsSingle(o => $"--source {o.Arguments.Single()}")),
|
|
||||||
Create.Option("--package-directory",
|
|
||||||
"Restore the packages to this Directory .",
|
|
||||||
Accept.ExactlyOneArgument()
|
|
||||||
.With(name: "PACKAGE_DIRECTORY")
|
|
||||||
.ForwardAsSingle(o => $"--package-directory {o.Arguments.Single()}"))),
|
|
||||||
Create.Command(
|
|
||||||
"reference",
|
|
||||||
Tools.Add.ProjectToProjectReference.LocalizableStrings.AppFullName,
|
|
||||||
Accept.OneOrMoreArguments()
|
|
||||||
.With(name: "args",
|
|
||||||
description: Tools.Add.ProjectToProjectReference.LocalizableStrings.AppHelpText),
|
|
||||||
CommonOptions.HelpOption(),
|
|
||||||
Create.Option("-f|--framework",
|
|
||||||
LocalizableStrings.CmdFrameworkDescription,
|
|
||||||
Accept
|
|
||||||
.ExactlyOneArgument()
|
|
||||||
.WithSuggestionsFrom(_ => Suggest.TargetFrameworksFromProjectFile())
|
|
||||||
.With(name: "FRAMEWORK"))),
|
|
||||||
CommonOptions.HelpOption());
|
CommonOptions.HelpOption());
|
||||||
|
|
||||||
public static IEnumerable<string> QueryNuGet(string match)
|
|
||||||
{
|
|
||||||
var httpClient = new HttpClient();
|
|
||||||
|
|
||||||
string result;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var cancellation = new CancellationTokenSource(TimeSpan.FromSeconds(10));
|
|
||||||
var response = httpClient.GetAsync($"https://api-v2v3search-0.nuget.org/query?q={match}&skip=0&take=100&prerelease=true", cancellation.Token)
|
|
||||||
.Result;
|
|
||||||
|
|
||||||
result = response.Content.ReadAsStringAsync().Result;
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
yield break;
|
|
||||||
}
|
|
||||||
|
|
||||||
var json = JObject.Parse(result);
|
|
||||||
|
|
||||||
foreach (var id in json["data"])
|
|
||||||
{
|
|
||||||
yield return id["id"].Value<string>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading;
|
||||||
|
using Microsoft.DotNet.Cli.CommandLine;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using LocalizableStrings = Microsoft.DotNet.Tools.Add.PackageReference.LocalizableStrings;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Cli
|
||||||
|
{
|
||||||
|
internal static class AddPackageParser
|
||||||
|
{
|
||||||
|
public static Command AddPackage()
|
||||||
|
{
|
||||||
|
return Create.Command(
|
||||||
|
"package",
|
||||||
|
LocalizableStrings.AppFullName,
|
||||||
|
Accept.ExactlyOneArgument(errorMessage: o => LocalizableStrings.SpecifyExactlyOnePackageReference)
|
||||||
|
.WithSuggestionsFrom(QueryNuGet)
|
||||||
|
.With(name: LocalizableStrings.CmdPackage,
|
||||||
|
description: LocalizableStrings.CmdPackageDescription),
|
||||||
|
CommonOptions.HelpOption(),
|
||||||
|
Create.Option("-v|--version",
|
||||||
|
LocalizableStrings.CmdVersionDescription,
|
||||||
|
Accept.ExactlyOneArgument()
|
||||||
|
.With(name: LocalizableStrings.CmdVersion)
|
||||||
|
.ForwardAsSingle(o => $"--version {o.Arguments.Single()}")),
|
||||||
|
Create.Option("-f|--framework",
|
||||||
|
LocalizableStrings.CmdFrameworkDescription,
|
||||||
|
Accept.ExactlyOneArgument()
|
||||||
|
.With(name: LocalizableStrings.CmdFramework)
|
||||||
|
.ForwardAsSingle(o => $"--framework {o.Arguments.Single()}")),
|
||||||
|
Create.Option("-n|--no-restore ",
|
||||||
|
LocalizableStrings.CmdNoRestoreDescription),
|
||||||
|
Create.Option("-s|--source",
|
||||||
|
LocalizableStrings.CmdSourceDescription,
|
||||||
|
Accept.ExactlyOneArgument()
|
||||||
|
.With(name: LocalizableStrings.CmdSource)
|
||||||
|
.ForwardAsSingle(o => $"--source {o.Arguments.Single()}")),
|
||||||
|
Create.Option("--package-directory",
|
||||||
|
LocalizableStrings.CmdPackageDirectoryDescription,
|
||||||
|
Accept.ExactlyOneArgument()
|
||||||
|
.With(name: LocalizableStrings.CmdPackageDirectory)
|
||||||
|
.ForwardAsSingle(o => $"--package-directory {o.Arguments.Single()}")));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<string> QueryNuGet(string match)
|
||||||
|
{
|
||||||
|
var httpClient = new HttpClient();
|
||||||
|
|
||||||
|
string result;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var cancellation = new CancellationTokenSource(TimeSpan.FromSeconds(10));
|
||||||
|
var response = httpClient.GetAsync($"https://api-v2v3search-0.nuget.org/query?q={match}&skip=0&take=100&prerelease=true", cancellation.Token)
|
||||||
|
.Result;
|
||||||
|
|
||||||
|
result = response.Content.ReadAsStringAsync().Result;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var json = JObject.Parse(result);
|
||||||
|
|
||||||
|
foreach (var id in json["data"])
|
||||||
|
{
|
||||||
|
yield return id["id"].Value<string>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
using Microsoft.DotNet.Cli.CommandLine;
|
||||||
|
using LocalizableStrings = Microsoft.DotNet.Tools.Add.ProjectToProjectReference.LocalizableStrings;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Cli
|
||||||
|
{
|
||||||
|
internal static class AddProjectToProjectReferenceParser
|
||||||
|
{
|
||||||
|
public static Command AddProjectReference()
|
||||||
|
{
|
||||||
|
return Create.Command(
|
||||||
|
"reference",
|
||||||
|
LocalizableStrings.AppFullName,
|
||||||
|
Accept.OneOrMoreArguments()
|
||||||
|
.With(name: "args",
|
||||||
|
description: LocalizableStrings.AppHelpText),
|
||||||
|
CommonOptions.HelpOption(),
|
||||||
|
Create.Option("-f|--framework", LocalizableStrings.CmdFrameworkDescription,
|
||||||
|
Accept.ExactlyOneArgument()
|
||||||
|
.WithSuggestionsFrom(_ => Suggest.TargetFrameworksFromProjectFile())
|
||||||
|
.With(name: Tools.Add.PackageReference.LocalizableStrings.CmdFramework)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.DotNet.Cli.CommandLine;
|
using Microsoft.DotNet.Cli.CommandLine;
|
||||||
|
using Microsoft.DotNet.Tools;
|
||||||
using LocalizableStrings = Microsoft.DotNet.Tools.Build.LocalizableStrings;
|
using LocalizableStrings = Microsoft.DotNet.Tools.Build.LocalizableStrings;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli
|
namespace Microsoft.DotNet.Cli
|
||||||
|
@ -14,7 +15,7 @@ namespace Microsoft.DotNet.Cli
|
||||||
"build",
|
"build",
|
||||||
LocalizableStrings.AppFullName,
|
LocalizableStrings.AppFullName,
|
||||||
Accept.ZeroOrMoreArguments()
|
Accept.ZeroOrMoreArguments()
|
||||||
.With(name: "PROJECT",
|
.With(name: CommonLocalizableStrings.CmdProjectFile,
|
||||||
description:
|
description:
|
||||||
"The MSBuild project file to build. If a project file is not specified, MSBuild searches the current working directory for a file that has a file extension that ends in `proj` and uses that file."),
|
"The MSBuild project file to build. If a project file is not specified, MSBuild searches the current working directory for a file that has a file extension that ends in `proj` and uses that file."),
|
||||||
CommonOptions.HelpOption(),
|
CommonOptions.HelpOption(),
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
using Microsoft.DotNet.Cli.CommandLine;
|
using Microsoft.DotNet.Cli.CommandLine;
|
||||||
using LocalizableStrings = Microsoft.DotNet.Tools.List.ProjectToProjectReferences.LocalizableStrings;
|
using Microsoft.DotNet.Tools;
|
||||||
|
using LocalizableStrings = Microsoft.DotNet.Tools.List.LocalizableStrings;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli
|
namespace Microsoft.DotNet.Cli
|
||||||
{
|
{
|
||||||
|
@ -10,15 +11,15 @@ namespace Microsoft.DotNet.Cli
|
||||||
{
|
{
|
||||||
public static Command List() =>
|
public static Command List() =>
|
||||||
Create.Command("list",
|
Create.Command("list",
|
||||||
".NET List Command",
|
LocalizableStrings.NetListCommand,
|
||||||
Accept.ZeroOrOneArgument()
|
Accept.ZeroOrOneArgument()
|
||||||
.With(name: "PROJECT",
|
.With(name: CommonLocalizableStrings.CmdProjectFile,
|
||||||
description:
|
description:
|
||||||
"The project file to operate on. If a file is not specified, the command will search the current directory for one.")
|
CommonLocalizableStrings.ArgumentsProjectDescription)
|
||||||
.DefaultToCurrentDirectory(),
|
.DefaultToCurrentDirectory(),
|
||||||
CommonOptions.HelpOption(),
|
CommonOptions.HelpOption(),
|
||||||
Create.Command("reference",
|
Create.Command("reference",
|
||||||
LocalizableStrings.AppFullName,
|
Tools.List.ProjectToProjectReferences.LocalizableStrings.AppFullName,
|
||||||
Accept.ZeroOrOneArgument(),
|
Accept.ZeroOrOneArgument(),
|
||||||
CommonOptions.HelpOption()));
|
CommonOptions.HelpOption()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,7 @@ namespace Microsoft.DotNet.Cli
|
||||||
".NET Migrate Command",
|
".NET Migrate Command",
|
||||||
Accept.ZeroOrOneArgument()
|
Accept.ZeroOrOneArgument()
|
||||||
.MaterializeAs(o =>
|
.MaterializeAs(o =>
|
||||||
{
|
new MigrateCommand(
|
||||||
return new MigrateCommand(
|
|
||||||
o.ValueOrDefault<string>("--template-file"),
|
o.ValueOrDefault<string>("--template-file"),
|
||||||
o.Arguments.FirstOrDefault(),
|
o.Arguments.FirstOrDefault(),
|
||||||
o.ValueOrDefault<string>("--sdk-package-version"),
|
o.ValueOrDefault<string>("--sdk-package-version"),
|
||||||
|
@ -25,8 +24,7 @@ namespace Microsoft.DotNet.Cli
|
||||||
o.ValueOrDefault<string>("--report-file"),
|
o.ValueOrDefault<string>("--report-file"),
|
||||||
o.ValueOrDefault<bool>("--skip-project-references"),
|
o.ValueOrDefault<bool>("--skip-project-references"),
|
||||||
o.ValueOrDefault<bool>("--format-report-file-json"),
|
o.ValueOrDefault<bool>("--format-report-file-json"),
|
||||||
o.ValueOrDefault<bool>("--skip-backup"));
|
o.ValueOrDefault<bool>("--skip-backup")))
|
||||||
})
|
|
||||||
.With(name: LocalizableStrings.CmdProjectArgument,
|
.With(name: LocalizableStrings.CmdProjectArgument,
|
||||||
description: LocalizableStrings.CmdProjectArgumentDescription),
|
description: LocalizableStrings.CmdProjectArgumentDescription),
|
||||||
CommonOptions.HelpOption(),
|
CommonOptions.HelpOption(),
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using Microsoft.DotNet.Cli.CommandLine;
|
using Microsoft.DotNet.Cli.CommandLine;
|
||||||
using Microsoft.DotNet.Tools;
|
using Microsoft.DotNet.Tools;
|
||||||
using LocalizableStrings = Microsoft.DotNet.Tools.Remove.ProjectToProjectReference.LocalizableStrings;
|
using LocalizableStrings = Microsoft.DotNet.Tools.Remove.LocalizableStrings;
|
||||||
|
|
||||||
namespace Microsoft.DotNet.Cli
|
namespace Microsoft.DotNet.Cli
|
||||||
{
|
{
|
||||||
|
@ -11,30 +11,14 @@ namespace Microsoft.DotNet.Cli
|
||||||
{
|
{
|
||||||
public static Command Remove() =>
|
public static Command Remove() =>
|
||||||
Create.Command("remove",
|
Create.Command("remove",
|
||||||
".NET Remove Command",
|
LocalizableStrings.NetRemoveCommand,
|
||||||
Accept.ExactlyOneArgument()
|
Accept.ExactlyOneArgument()
|
||||||
.DefaultToCurrentDirectory()
|
.DefaultToCurrentDirectory()
|
||||||
.With(name: "PROJECT",
|
.With(name: CommonLocalizableStrings.CmdProjectFile,
|
||||||
description: CommonLocalizableStrings.ArgumentsProjectDescription)
|
description: CommonLocalizableStrings.ArgumentsProjectDescription)
|
||||||
.DefaultToCurrentDirectory(),
|
.DefaultToCurrentDirectory(),
|
||||||
CommonOptions.HelpOption(),
|
CommonOptions.HelpOption(),
|
||||||
Create.Command(
|
RemovePackageParser.RemovePackage(),
|
||||||
"package",
|
RemoveProjectToProjectReferenceParser.RemoveReference());
|
||||||
LocalizableStrings.AppFullName,
|
|
||||||
CommonOptions.HelpOption()),
|
|
||||||
Create.Command(
|
|
||||||
"reference",
|
|
||||||
LocalizableStrings.AppFullName,
|
|
||||||
Accept
|
|
||||||
.OneOrMoreArguments()
|
|
||||||
.WithSuggestionsFrom(_ => Suggest.ProjectReferencesFromProjectFile())
|
|
||||||
.With(name: "args",
|
|
||||||
description: LocalizableStrings.AppHelpText),
|
|
||||||
CommonOptions.HelpOption(),
|
|
||||||
Create.Option(
|
|
||||||
"-f|--framework",
|
|
||||||
"Remove reference only when targeting a specific framework",
|
|
||||||
Accept.ExactlyOneArgument()
|
|
||||||
.With(name: "FRAMEWORK"))));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
using Microsoft.DotNet.Cli.CommandLine;
|
||||||
|
using LocalizableStrings = Microsoft.DotNet.Tools.Remove.ProjectToProjectReference.LocalizableStrings;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Cli
|
||||||
|
{
|
||||||
|
internal static class RemovePackageParser
|
||||||
|
{
|
||||||
|
public static Command RemovePackage() =>
|
||||||
|
Create.Command(
|
||||||
|
"package",
|
||||||
|
LocalizableStrings.AppFullName,
|
||||||
|
CommonOptions.HelpOption());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
using Microsoft.DotNet.Cli.CommandLine;
|
||||||
|
using Microsoft.DotNet.Tools;
|
||||||
|
using LocalizableStrings = Microsoft.DotNet.Tools.Remove.ProjectToProjectReference.LocalizableStrings;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Cli
|
||||||
|
{
|
||||||
|
internal static class RemoveProjectToProjectReferenceParser
|
||||||
|
{
|
||||||
|
public static Command RemoveReference() =>
|
||||||
|
Create.Command(
|
||||||
|
"reference",
|
||||||
|
LocalizableStrings.AppFullName,
|
||||||
|
Accept
|
||||||
|
.OneOrMoreArguments()
|
||||||
|
.WithSuggestionsFrom(_ => Suggest.ProjectReferencesFromProjectFile())
|
||||||
|
.With(name: "args",
|
||||||
|
description: LocalizableStrings.AppHelpText),
|
||||||
|
CommonOptions.HelpOption(),
|
||||||
|
Create.Option(
|
||||||
|
"-f|--framework",
|
||||||
|
LocalizableStrings.CmdFrameworkDescription,
|
||||||
|
Accept.ExactlyOneArgument()
|
||||||
|
.With(name: CommonLocalizableStrings.CmdFramework)));
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,14 +16,10 @@ namespace Microsoft.DotNet.Tools.Run
|
||||||
public string Configuration { get; set; }
|
public string Configuration { get; set; }
|
||||||
public string Framework { get; set; }
|
public string Framework { get; set; }
|
||||||
public string Project { get; set; }
|
public string Project { get; set; }
|
||||||
public IReadOnlyList<string> Args { get; set; }
|
public IReadOnlyCollection<string> Args { get; set; }
|
||||||
|
|
||||||
private List<string> _args;
|
private List<string> _args;
|
||||||
|
|
||||||
public RunCommand()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Start()
|
public int Start()
|
||||||
{
|
{
|
||||||
Initialize();
|
Initialize();
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.DotNet.Cli.CommandLine;
|
using Microsoft.DotNet.Cli.CommandLine;
|
||||||
using Microsoft.DotNet.Tools.Run;
|
using Microsoft.DotNet.Tools.Run;
|
||||||
using LocalizableStrings = Microsoft.DotNet.Tools.Run.LocalizableStrings;
|
using LocalizableStrings = Microsoft.DotNet.Tools.Run.LocalizableStrings;
|
||||||
|
@ -14,17 +13,17 @@ namespace Microsoft.DotNet.Cli
|
||||||
Create.Command(
|
Create.Command(
|
||||||
"run",
|
"run",
|
||||||
LocalizableStrings.AppFullName,
|
LocalizableStrings.AppFullName,
|
||||||
Accept.ZeroOrMoreArguments()
|
treatUnmatchedTokensAsErrors: false,
|
||||||
.MaterializeAs(o =>
|
arguments: Accept.ZeroOrMoreArguments()
|
||||||
{
|
.MaterializeAs(o => new RunCommand
|
||||||
return new RunCommand()
|
|
||||||
{
|
{
|
||||||
Configuration = o.SingleArgumentOrDefault("--configuration"),
|
Configuration = o.SingleArgumentOrDefault("--configuration"),
|
||||||
Framework = o.SingleArgumentOrDefault("--framework"),
|
Framework = o.SingleArgumentOrDefault("--framework"),
|
||||||
Project = o.SingleArgumentOrDefault("--project"),
|
Project = o.SingleArgumentOrDefault("--project"),
|
||||||
Args = (IReadOnlyList<string>)o.Arguments
|
Args = o.Arguments
|
||||||
};
|
|
||||||
}),
|
}),
|
||||||
|
options: new[]
|
||||||
|
{
|
||||||
CommonOptions.HelpOption(),
|
CommonOptions.HelpOption(),
|
||||||
CommonOptions.ConfigurationOption(),
|
CommonOptions.ConfigurationOption(),
|
||||||
CommonOptions.FrameworkOption(),
|
CommonOptions.FrameworkOption(),
|
||||||
|
@ -35,6 +34,7 @@ namespace Microsoft.DotNet.Cli
|
||||||
Create.Option(
|
Create.Option(
|
||||||
"--no-build",
|
"--no-build",
|
||||||
LocalizableStrings.CommandOptionNoBuildDescription,
|
LocalizableStrings.CommandOptionNoBuildDescription,
|
||||||
Accept.NoArguments().ForwardAs("/p:NoBuild=true")));
|
Accept.NoArguments().ForwardAs("/p:NoBuild=true"))
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,27 +12,14 @@ namespace Microsoft.DotNet.Cli
|
||||||
public static Command Sln() =>
|
public static Command Sln() =>
|
||||||
Create.Command(
|
Create.Command(
|
||||||
"sln",
|
"sln",
|
||||||
".NET modify solution file command",
|
LocalizableStrings.AppFullName,
|
||||||
Accept.ExactlyOneArgument()
|
Accept.ExactlyOneArgument()
|
||||||
.DefaultToCurrentDirectory()
|
.DefaultToCurrentDirectory()
|
||||||
.With(name: "SLN_FILE",
|
.With(name: CommonLocalizableStrings.CmdSlnFile,
|
||||||
description: CommonLocalizableStrings.ArgumentsSolutionDescription),
|
description: CommonLocalizableStrings.ArgumentsSolutionDescription),
|
||||||
CommonOptions.HelpOption(),
|
CommonOptions.HelpOption(),
|
||||||
Create.Command("add",
|
SlnAddParser.SlnAdd(),
|
||||||
".NET Add project(s) to a solution file Command",
|
SlnListParser.SlnList(),
|
||||||
Accept.OneOrMoreArguments(o => CommonLocalizableStrings.SpecifyAtLeastOneProjectToAdd)
|
SlnRemoveParser.SlnRemove());
|
||||||
.With(name: "args",
|
|
||||||
description: LocalizableStrings.AddSubcommandHelpText),
|
|
||||||
CommonOptions.HelpOption()),
|
|
||||||
Create.Command("list",
|
|
||||||
".NET List project(s) in a solution file Command",
|
|
||||||
CommonOptions.HelpOption()),
|
|
||||||
Create.Command("remove",
|
|
||||||
".NET Remove project(s) from a solution file Command",
|
|
||||||
Accept.OneOrMoreArguments(o => CommonLocalizableStrings.SpecifyAtLeastOneProjectToRemove)
|
|
||||||
.With(name: "args",
|
|
||||||
description: LocalizableStrings.RemoveSubcommandHelpText),
|
|
||||||
CommonOptions.HelpOption()));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
20
src/dotnet/commands/dotnet-sln/add/SlnAddParser.cs
Normal file
20
src/dotnet/commands/dotnet-sln/add/SlnAddParser.cs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
using Microsoft.DotNet.Cli.CommandLine;
|
||||||
|
using Microsoft.DotNet.Tools;
|
||||||
|
using LocalizableStrings = Microsoft.DotNet.Tools.Sln.LocalizableStrings;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Cli
|
||||||
|
{
|
||||||
|
public static class SlnAddParser
|
||||||
|
{
|
||||||
|
public static Command SlnAdd() =>
|
||||||
|
Create.Command("add",
|
||||||
|
LocalizableStrings.AddAppFullName,
|
||||||
|
Accept.OneOrMoreArguments(o => CommonLocalizableStrings.SpecifyAtLeastOneProjectToAdd)
|
||||||
|
.With(name: "args",
|
||||||
|
description: LocalizableStrings.AddSubcommandHelpText),
|
||||||
|
CommonOptions.HelpOption());
|
||||||
|
}
|
||||||
|
}
|
16
src/dotnet/commands/dotnet-sln/list/SlnListParser.cs
Normal file
16
src/dotnet/commands/dotnet-sln/list/SlnListParser.cs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
using Microsoft.DotNet.Cli.CommandLine;
|
||||||
|
using LocalizableStrings = Microsoft.DotNet.Tools.Sln.LocalizableStrings;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Cli
|
||||||
|
{
|
||||||
|
public static class SlnListParser
|
||||||
|
{
|
||||||
|
public static Command SlnList() =>
|
||||||
|
Create.Command("list",
|
||||||
|
LocalizableStrings.ListAppFullName,
|
||||||
|
CommonOptions.HelpOption());
|
||||||
|
}
|
||||||
|
}
|
20
src/dotnet/commands/dotnet-sln/remove/SlnRemoveParser.cs
Normal file
20
src/dotnet/commands/dotnet-sln/remove/SlnRemoveParser.cs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
using Microsoft.DotNet.Cli.CommandLine;
|
||||||
|
using Microsoft.DotNet.Tools;
|
||||||
|
using LocalizableStrings = Microsoft.DotNet.Tools.Sln.LocalizableStrings;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Cli
|
||||||
|
{
|
||||||
|
public static class SlnRemoveParser
|
||||||
|
{
|
||||||
|
public static Command SlnRemove() =>
|
||||||
|
Create.Command("remove",
|
||||||
|
LocalizableStrings.RemoveAppFullName,
|
||||||
|
Accept.OneOrMoreArguments(o => CommonLocalizableStrings.SpecifyAtLeastOneProjectToRemove)
|
||||||
|
.With(name: "args",
|
||||||
|
description: LocalizableStrings.RemoveSubcommandHelpText),
|
||||||
|
CommonOptions.HelpOption());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue