mirror of
https://github.com/yaakov-h/Shamir.git
synced 2025-04-19 21:15:20 +00:00
implement "cdn ls" via CommandLineParser
This commit is contained in:
parent
74c7070e38
commit
a4f9f13780
7 changed files with 113 additions and 8 deletions
|
@ -1,5 +1,7 @@
|
|||
using System.Collections.Immutable;
|
||||
using System.Threading.Tasks;
|
||||
using CommandLine;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Shamir.Console
|
||||
{
|
||||
|
@ -7,19 +9,29 @@ namespace Shamir.Console
|
|||
{
|
||||
public static async Task<int> Main(string[] args)
|
||||
{
|
||||
await using var serviceProvider = new ServiceCollection()
|
||||
.AddTransient<Parser>(sp => new Parser(with => with.EnableDashDash = true))
|
||||
.BuildServiceProvider();
|
||||
|
||||
var tree = new DefaultCommandTree(
|
||||
"shamir",
|
||||
"command-line multitool",
|
||||
ImmutableArray.Create<ICommandTree>(
|
||||
|
||||
new DefaultCommandTree(
|
||||
"cdn",
|
||||
"Browse and add new data to a CDN backed by Azure Storage",
|
||||
ImmutableArray<ICommandTree>.Empty,
|
||||
ImmutableArray.Create<ICommand>(
|
||||
new StorageLsCommand()
|
||||
))
|
||||
),
|
||||
ImmutableArray.Create<ICommand>(
|
||||
|
||||
)
|
||||
ImmutableArray<ICommand>.Empty
|
||||
);
|
||||
|
||||
var command = tree.FindCommand(args);
|
||||
return await command.ExecuteAsync();
|
||||
|
||||
using var scope = serviceProvider.CreateScope();
|
||||
return await command.ExecuteAsync(scope.ServiceProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue