Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
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;
}
}
}