-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
47 lines (43 loc) · 1.75 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
using CommandLine;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using TFSCodeReviewTool.Managers.Managers;
using TFSCodeReviewTool.ReportDataSources;
namespace TFSCodeReviewTool
{
internal static class Program
{
static void Main(string[] args)
{
Parser.Default.ParseArguments<Options>(args)
.WithParsed(RunOptions)
.WithNotParsed((err) => err.Output());
}
static void RunOptions(Options opts)
{
var tfsManager = new TFSManager(opts.ProjectName);
var saveLocationFilePath = string.IsNullOrEmpty(opts.SaveLocationFilePath) ? Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) : opts.SaveLocationFilePath;
var reportManager = new ReportManager(saveLocationFilePath, opts.FileNameFormatString, opts.DateTimeFormatString);
var reportDataSources = new List<CodeReviewReportDataSource>();
foreach (var reviewId in opts.ReviewWorkItemIds)
{
var codeReviewData = tfsManager.GetCodeReviewComments(reviewId);
if (codeReviewData != default) { reportDataSources.Add(new CodeReviewReportDataSource(codeReviewData)); }
}
if (opts.IndividualReports)
{
reportDataSources.ForEach(rds =>
{
var filePath = reportManager.GenerateCodeReviewReportPDF(rds);
if (opts.AutoOpenPDF) { Process.Start(filePath); }
});
}
else
{
var filePath = reportManager.GenerateCodeReviewReportPDF(reportDataSources);
if (opts.AutoOpenPDF) { Process.Start(filePath); }
}
}
}
}