Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
51 lines (47 sloc) 1.51 KB
namespace SuperTool
{
using System.Reflection;
using System.Threading.Tasks;
using AutoMapper;
using McMaster.Extensions.CommandLineUtils;
using MediatR;
using Microsoft.Extensions.Hosting;
[Command(Name = "SuperTool",
Description = "Run helpful utilities for my application")]
[HelpOption]
[VersionOptionFromMember(MemberName = "GetVersion")]
[Subcommand(
typeof(Features.When.Commands.WhenCommand),
typeof(Features.DoMath.Commands.DoMathCommand))
]
internal class Program
{
private static async Task Main(string[] args)
{
await CreateHostBuilder()
.RunCommandLineApplicationAsync<Program>(args);
}
public static IHostBuilder CreateHostBuilder()
{
return Host.CreateDefaultBuilder()
.ConfigureServices((hostContext, services) =>
{
services
.AddMediatR(typeof(Program).Assembly)
.AddAutoMapper(typeof(Program).Assembly);
});
}
private int OnExecute(CommandLineApplication app, IConsole console)
{
console.WriteLine("You must specify a command");
app.ShowHelp();
return 1;
}
private string GetVersion()
{
return typeof(Program).Assembly
?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
?.InformationalVersion;
}
}
}
You can’t perform that action at this time.