2021-09-25 23:29:46 +10:00
|
|
|
|
using System.Collections.Immutable;
|
2021-09-25 23:04:18 +10:00
|
|
|
|
using System.Threading.Tasks;
|
2021-09-26 00:07:48 +10:00
|
|
|
|
using CommandLine;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2021-09-25 23:04:18 +10:00
|
|
|
|
|
|
|
|
|
namespace Shamir.Console
|
|
|
|
|
{
|
2021-09-25 23:29:46 +10:00
|
|
|
|
public static class Program
|
2021-09-25 23:04:18 +10:00
|
|
|
|
{
|
2021-09-25 23:29:46 +10:00
|
|
|
|
public static async Task<int> Main(string[] args)
|
2021-09-25 23:04:18 +10:00
|
|
|
|
{
|
2021-09-26 00:07:48 +10:00
|
|
|
|
await using var serviceProvider = new ServiceCollection()
|
2021-09-26 00:33:10 +10:00
|
|
|
|
.AddTransient<Parser>(sp => new Parser(with =>
|
|
|
|
|
{
|
|
|
|
|
with.AutoHelp = true;
|
|
|
|
|
with.AutoVersion = true;
|
|
|
|
|
with.EnableDashDash = true;
|
|
|
|
|
with.IgnoreUnknownArguments = false;
|
|
|
|
|
}))
|
2021-09-26 00:07:48 +10:00
|
|
|
|
.BuildServiceProvider();
|
|
|
|
|
|
2021-09-25 23:29:46 +10:00
|
|
|
|
var tree = new DefaultCommandTree(
|
|
|
|
|
"shamir",
|
|
|
|
|
"command-line multitool",
|
|
|
|
|
ImmutableArray.Create<ICommandTree>(
|
2021-09-26 00:07:48 +10:00
|
|
|
|
new DefaultCommandTree(
|
|
|
|
|
"cdn",
|
|
|
|
|
"Browse and add new data to a CDN backed by Azure Storage",
|
|
|
|
|
ImmutableArray<ICommandTree>.Empty,
|
|
|
|
|
ImmutableArray.Create<ICommand>(
|
2021-09-26 13:39:45 +10:00
|
|
|
|
new StorageLsCommand(),
|
2021-09-26 14:00:51 +10:00
|
|
|
|
new StorageCopyCommand(),
|
2021-09-26 14:07:50 +10:00
|
|
|
|
new StorageGetUrlCommand()
|
2021-09-30 18:12:02 +10:00
|
|
|
|
)),
|
|
|
|
|
new DefaultCommandTree(
|
|
|
|
|
"vk",
|
|
|
|
|
"Australian Amateur Radio commands",
|
|
|
|
|
ImmutableArray<ICommandTree>.Empty,
|
|
|
|
|
ImmutableArray.Create<ICommand>(
|
|
|
|
|
new VKLookupCommand()
|
2021-09-26 00:07:48 +10:00
|
|
|
|
))
|
2021-09-25 23:29:46 +10:00
|
|
|
|
),
|
2021-09-26 00:07:48 +10:00
|
|
|
|
ImmutableArray<ICommand>.Empty
|
2021-09-25 23:04:18 +10:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
var command = tree.FindCommand(args);
|
2021-09-26 00:07:48 +10:00
|
|
|
|
|
|
|
|
|
using var scope = serviceProvider.CreateScope();
|
|
|
|
|
return await command.ExecuteAsync(scope.ServiceProvider);
|
2021-09-25 23:04:18 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|