Skip to content

Commit

Permalink
Start using HostBuilder with CommandLineUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
christophwille committed Jul 12, 2023
1 parent 5156a9d commit 8e3c1af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion ICSharpCode.ILSpyCmd/ICSharpCode.ILSpyCmd.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.0.2" />
<PackageReference Include=" McMaster.Extensions.Hosting.CommandLine" Version="4.0.2" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
</ItemGroup>

<Target Name="ILSpyUpdateAssemblyInfo" AfterTargets="ResolveProjectReferences">
Expand Down
10 changes: 9 additions & 1 deletion ICSharpCode.ILSpyCmd/IlspyCmdProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

using McMaster.Extensions.CommandLineUtils;

using Microsoft.Extensions.Hosting;

namespace ICSharpCode.ILSpyCmd
{
[Command(Name = "ilspycmd", Description = "dotnet tool for decompiling .NET assemblies and generating portable PDBs",
Expand Down Expand Up @@ -49,7 +51,7 @@ into nicely nested directories.
MemberName = nameof(DecompilerVersion))]
class ILSpyCmdProgram
{
public static Task<int> Main(string[] args) => CommandLineApplication.ExecuteAsync<ILSpyCmdProgram>(args);
public static Task<int> Main(string[] args) => new HostBuilder().RunCommandLineApplicationAsync<ILSpyCmdProgram>(args);

[FilesExist]
[Required]
Expand Down Expand Up @@ -107,6 +109,12 @@ class ILSpyCmdProgram
[Option("--nested-directories", "Use nested directories for namespaces.", CommandOptionType.NoValue)]
public bool NestedDirectories { get; }

private readonly IHostEnvironment _env;
public ILSpyCmdProgram(IHostEnvironment env)
{
_env = env;
}

private Task<int> OnExecuteAsync(CommandLineApplication app)
{
TextWriter output = System.Console.Out;
Expand Down

0 comments on commit 8e3c1af

Please sign in to comment.