This repository has been archived by the owner on Apr 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replacing the commandline parser in dotnet-dependency-tool-invoker wi…
…th the CliCommandLineParser.
- Loading branch information
Showing
5 changed files
with
138 additions
and
136 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
TestAssets/TestPackages/dotnet-dependency-tool-invoker/AppliedOptionsExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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.Linq; | ||
using Microsoft.DotNet.Cli.CommandLine; | ||
|
||
namespace Microsoft.DotNet.Tools.DependencyInvoker | ||
{ | ||
public static class AppliedOptionExtensions | ||
{ | ||
public static T ValueOrDefault<T>(this AppliedOption parseResult, string alias) | ||
{ | ||
return parseResult | ||
.AppliedOptions | ||
.Where(o => o.HasAlias(alias)) | ||
.Select(o => o.Value<T>()) | ||
.SingleOrDefault(); | ||
} | ||
|
||
public static string SingleArgumentOrDefault(this AppliedOption parseResult, string alias) | ||
{ | ||
return parseResult | ||
.AppliedOptions | ||
.Where(o => o.HasAlias(alias)) | ||
.Select(o => o.Arguments.Single()) | ||
.SingleOrDefault(); | ||
} | ||
} | ||
} |
113 changes: 0 additions & 113 deletions
113
TestAssets/TestPackages/dotnet-dependency-tool-invoker/DotnetBaseParams.cs
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
TestAssets/TestPackages/dotnet-dependency-tool-invoker/DotnetDependencyToolInvokerParser.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// 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.IO; | ||
using System.Linq; | ||
using Microsoft.DotNet.Cli.CommandLine; | ||
using Microsoft.DotNet.Tools.Common; | ||
using Microsoft.DotNet.Cli.Utils; | ||
using NuGet.Frameworks; | ||
|
||
namespace Microsoft.DotNet.Tools.DependencyInvoker | ||
{ | ||
internal static class DotnetDependencyToolInvokerParser | ||
{ | ||
public static Microsoft.DotNet.Cli.CommandLine.Command DotnetDependencyToolInvoker() => | ||
Create.Command( | ||
"dotnet-dependency-tool-invoker", | ||
"DotNet Dependency Tool Invoker", | ||
Accept.ExactlyOneArgument() | ||
.With(name: "COMMAND", | ||
description: "The command to execute."), | ||
false, | ||
Create.Option( | ||
"-h|--help", | ||
"Show help information", | ||
Accept.NoArguments(), | ||
materialize: o => o.Option.Command().HelpView()), | ||
Create.Option( | ||
"-p|--project-path", | ||
"Path to Project.json that contains the tool dependency", | ||
Accept.ExactlyOneArgument() | ||
.With(name: "PROJECT_JSON_PATH", | ||
defaultValue: () => | ||
PathUtility.EnsureTrailingSlash(Directory.GetCurrentDirectory()))), | ||
Create.Option( | ||
"-c|--configuration", | ||
"Configuration under which to build", | ||
Accept.ExactlyOneArgument() | ||
.With(name: "CONFIGURATION", | ||
defaultValue: () => Constants.DefaultConfiguration)), | ||
Create.Option( | ||
"-o|--output", | ||
"Directory in which to find the binaries to be run", | ||
Accept.ExactlyOneArgument() | ||
.With(name: "OUTPUT_DIR")), | ||
Create.Option( | ||
"-f|--framework", | ||
"Looks for test binaries for a specific framework", | ||
Accept.ExactlyOneArgument() | ||
.With(name: "FRAMEWORK") | ||
.MaterializeAs(p => NuGetFramework.Parse(p.Arguments.Single()))), | ||
Create.Option( | ||
"-r|--runtime", | ||
"Look for test binaries for a for the specified runtime", | ||
Accept.ExactlyOneArgument() | ||
.With(name: "RUNTIME_IDENTIFIER"))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters