forked from winsw/winsw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
206 additions
and
149 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
using System.Runtime.CompilerServices; | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: AssemblyMetadata("IsTrimmable", "True")] | ||
[assembly: InternalsVisibleTo("WinSW")] | ||
[assembly: InternalsVisibleTo("WinSW.Tests")] |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
using System.Runtime.CompilerServices; | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: AssemblyMetadata("IsTrimmable", "True")] | ||
[assembly: InternalsVisibleTo("WinSW.Tests")] |
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,41 @@ | ||
using System; | ||
using System.CommandLine; | ||
using System.CommandLine.Invocation; | ||
|
||
namespace WinSW | ||
{ | ||
internal static class CommandExtensions | ||
{ | ||
internal static void SetHandler<T>(this Command command, Action<T, InvocationContext> handle, Argument<T> symbol) | ||
{ | ||
command.SetHandler(context => | ||
{ | ||
var value = context.ParseResult.GetValueForArgument(symbol); | ||
handle(value!, context); | ||
}); | ||
} | ||
|
||
internal static void SetHandler<T1, T2, T3>(this Command command, Action<T1, T2, T3, InvocationContext> handle, Argument<T1> symbol1, Option<T2> symbol2, Option<T3> symbol3) | ||
{ | ||
command.SetHandler(context => | ||
{ | ||
var value1 = context.ParseResult.GetValueForArgument(symbol1); | ||
var value2 = context.ParseResult.GetValueForOption(symbol2); | ||
var value3 = context.ParseResult.GetValueForOption(symbol3); | ||
handle(value1!, value2!, value3!, context); | ||
}); | ||
} | ||
|
||
internal static void SetHandler<T1, T2, T3, T4>(this Command command, Action<T1, T2, T3, T4, InvocationContext> handle, Argument<T1> symbol1, Option<T2> symbol2, Option<T3> symbol3, Option<T4> symbol4) | ||
{ | ||
command.SetHandler(context => | ||
{ | ||
var value1 = context.ParseResult.GetValueForArgument(symbol1); | ||
var value2 = context.ParseResult.GetValueForOption(symbol2); | ||
var value3 = context.ParseResult.GetValueForOption(symbol3); | ||
var value4 = context.ParseResult.GetValueForOption(symbol4); | ||
handle(value1!, value2!, value3!, value4!, context); | ||
}); | ||
} | ||
} | ||
} |
Oops, something went wrong.