mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
defer resolving of IMediator
This commit is contained in:
parent
1a3e7b8dc0
commit
b251813955
2 changed files with 13 additions and 5 deletions
|
|
@ -15,5 +15,10 @@ public CommandLineOptions(bool archiveLists, bool validateUrls)
|
|||
|
||||
[Option('v', "validate", Required = false, HelpText = "Validate all URLs in the FilterLists database.")]
|
||||
public bool ValidateUrls { get; }
|
||||
|
||||
public bool Any()
|
||||
{
|
||||
return ArchiveLists || ValidateUrls;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -17,13 +17,16 @@ public static async Task Main(string[] args)
|
|||
{
|
||||
_serviceProvider = ServiceProviderBuilder.Build();
|
||||
var parser = _serviceProvider.GetService<Parser>();
|
||||
var mediator = _serviceProvider.GetService<IMediator>();
|
||||
await parser.ParseArguments<CommandLineOptions>(args).MapResult(async o =>
|
||||
{
|
||||
if (o.ArchiveLists)
|
||||
await mediator.Send(new ArchiveLists.Command());
|
||||
if (o.ValidateUrls)
|
||||
await mediator.Send(new ValidateAllUrls.Command());
|
||||
if (o.Any())
|
||||
{
|
||||
var mediator = _serviceProvider.GetService<IMediator>();
|
||||
if (o.ArchiveLists)
|
||||
await mediator.Send(new ArchiveLists.Command());
|
||||
if (o.ValidateUrls)
|
||||
await mediator.Send(new ValidateAllUrls.Command());
|
||||
}
|
||||
},
|
||||
e => Task.FromResult(0)
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue