-
Notifications
You must be signed in to change notification settings - Fork 5
/
Program.cs
99 lines (89 loc) · 4.08 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using Smi.Common.Options;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
namespace Applications.SmiRunner
{
[ExcludeFromCodeCoverage]
public static class Program
{
public static readonly Type[] AllApplications =
{
typeof(DicomLoaderVerb),
typeof(DicomDirectoryProcessorVerb),
typeof(ExtractImagesVerb),
typeof(TriggerUpdatesVerb),
typeof(SetupVerb),
typeof(DynamicRulesTesterVerb),
};
public static readonly Type[] AllServices =
{
typeof(CohortExtractorVerb),
typeof(DicomAnonymiserVerb),
typeof(CohortPackagerVerb),
typeof(DicomRelationalMapperVerb),
typeof(DicomReprocessorVerb),
typeof(DicomTagReaderVerb),
typeof(FileCopierVerb),
typeof(IdentifierMapperVerb),
typeof(IsIdentifiableVerb),
typeof(MongoDbPopulatorVerb),
typeof(UpdateValuesVerb),
};
internal static int Main(string[] args)
{
var rest = args.Skip(1);
var allTypes = new List<Type>(AllApplications);
allTypes.AddRange(AllServices);
int res;
try
{
res = SmiCliInit.ParseServiceVerbAndRun(
args.Take(1),
allTypes.ToArray(),
service =>
{
// TODO(rkm 2021-02-26) Probably want to test that every case is covered here
return service switch
{
// Applications
DicomLoaderVerb _ => Applications.DicomLoader.Program.Main(rest),
DynamicRulesTesterVerb _ => Applications.DynamicRulesTester.Program.Main(rest),
TriggerUpdatesVerb _ => Applications.TriggerUpdates.Program.Main(rest),
DicomDirectoryProcessorVerb _ => Applications.DicomDirectoryProcessor.Program.Main(rest),
ExtractImagesVerb _ => ExtractImages.Program.Main(rest),
SetupVerb _ => Setup.Program.Main(rest),
// Microservices
CohortExtractorVerb _ => Microservices.CohortExtractor.Program.Main(rest),
CohortPackagerVerb _ => Microservices.CohortPackager.Program.Main(rest),
DicomAnonymiserVerb _ => Microservices.DicomAnonymiser.Program.Main(rest),
DicomRelationalMapperVerb _ => Microservices.DicomRelationalMapper.Program.Main(rest),
DicomReprocessorVerb _ => Microservices.DicomReprocessor.Program.Main(rest),
DicomTagReaderVerb _ => Microservices.DicomTagReader.Program.Main(rest),
FileCopierVerb _ => Microservices.FileCopier.Program.Main(rest),
IdentifierMapperVerb _ => Microservices.IdentifierMapper.Program.Main(rest),
IsIdentifiableVerb _ => Microservices.IsIdentifiable.Program.Main(rest),
MongoDbPopulatorVerb _ => Microservices.MongoDBPopulator.Program.Main(rest),
UpdateValuesVerb _ => Microservices.UpdateValues.Program.Main(rest),
_ => throw new ArgumentException($"No case for {nameof(service)}")
};
}
);
}
catch (Exception e)
{
Console.Error.WriteLine(e);
const int rc = 1;
Console.Error.WriteLine($"\nError (exit code {rc}): {e.Message}");
return rc;
}
if(args.Any(a=>a.Equals("--help")))
{
Console.WriteLine("Read more at:");
Console.WriteLine("https://github.com/SMI/SmiServices/tree/main/");
}
return res;
}
}
}