Skip to content

Commit ec67d16

Browse files
committed
System.CommandLine.Experimental -> CommandLineParser
1 parent 4dceb02 commit ec67d16

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

src/LazyCoder.Runner/LazyCoder.Runner.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</ItemGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="System.CommandLine.Experimental" Version="0.1.0-alpha-63724-02" />
14+
<PackageReference Include="CommandLineParser" Version="2.4.3" />
1515
</ItemGroup>
1616

1717
</Project>

src/LazyCoder.Runner/Program.cs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
1-
using System.CommandLine;
2-
using System.CommandLine.Builder;
3-
using System.CommandLine.Invocation;
4-
using System.Threading.Tasks;
1+
using CommandLine;
52

63
namespace LazyCoder.Runner
74
{
85
class Program
96
{
10-
private static async Task<int> Main(string[] args)
7+
private static void Main(string[] args)
118
{
12-
var parser = new CommandLineBuilder(new Command("lazy", handler: CommandHandler.Create(typeof(Runner).GetMethod(nameof(Runner.Run)))))
13-
.AddOption(new Option(new[] { "-dll" },
14-
argument: new Argument<string>("../../tests/LazyCoder.TestDll/bin/Debug/netstandard2.0/LazyCoder.TestDll.dll")
15-
{ Arity = ArgumentArity.ExactlyOne }))
16-
.AddOption(new Option(new[] { "-o", "-output", "-outputDirectory" },
17-
argument: new Argument<string>("./output")
18-
{ Arity = ArgumentArity.ExactlyOne }))
19-
.UseExceptionHandler()
20-
.Build();
9+
Parser.Default.ParseArguments<Options>(args)
10+
.WithParsed(o => Runner.Run(o.Dll, o.Output));
11+
}
12+
13+
private class Options
14+
{
15+
[Option("dll", Default = "../../tests/LazyCoder.TestDll/bin/Debug/netstandard2.0/LazyCoder.TestDll.dll")]
16+
public string Dll { get; set; }
2117

22-
return await parser.InvokeAsync(args).ConfigureAwait(false);
18+
[Option("output", Default = "./output")]
19+
public string Output { get; set; }
2320
}
2421
}
2522
}

0 commit comments

Comments
 (0)