wip: starting work on dir option
This commit is contained in:
222
Program.cs
222
Program.cs
@@ -22,119 +22,141 @@ static class Program
|
||||
);
|
||||
tagOption.AddAlias("-t");
|
||||
|
||||
var dirOption = new Option<string>(
|
||||
"--file",
|
||||
"Specify a git directory"
|
||||
);
|
||||
dirOption.AddAlias("-f");
|
||||
|
||||
var rootCommand = new RootCommand("Get a tally of contributors' commits")
|
||||
{
|
||||
outputOption,
|
||||
branchOption,
|
||||
tagOption,
|
||||
dirOption,
|
||||
};
|
||||
|
||||
rootCommand.SetHandler((outputOptionValue, branchOptionValue, tagOptionValue) => {
|
||||
CommitDetail commits = new CommitDetail();
|
||||
|
||||
switch (outputOptionValue)
|
||||
rootCommand.SetHandler((outputOptionValue, branchOptionValue, tagOptionValue, dirOptionValue) =>
|
||||
{
|
||||
CommitDetail commits = new CommitDetail(dirOptionValue);
|
||||
|
||||
switch (outputOptionValue)
|
||||
{
|
||||
case "stdout":
|
||||
StdOutDataService outDataService = new StdOutDataService();
|
||||
DataAccess dataAccess = new DataAccess(outDataService);
|
||||
|
||||
if (branchOptionValue != null && tagOptionValue != null)
|
||||
{
|
||||
case "stdout":
|
||||
StdOutDataService outDataService = new StdOutDataService();
|
||||
DataAccess dataAccess = new DataAccess(outDataService);
|
||||
|
||||
if (branchOptionValue != null && tagOptionValue != null) {
|
||||
Console.WriteLine("Please specify either a branch or a tag");
|
||||
Environment.Exit(2);
|
||||
} else if (branchOptionValue != null && tagOptionValue == null) {
|
||||
switch (branchOptionValue)
|
||||
{
|
||||
case null:
|
||||
commits.GetCurrentCommitsByName();
|
||||
dataAccess.WriteData(commits.CommitDetails);
|
||||
break;
|
||||
default:
|
||||
commits.GetCommitsByBranch(branchOptionValue);
|
||||
dataAccess.WriteData(commits.CommitDetails);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
} else if (branchOptionValue == null && tagOptionValue != null) {
|
||||
commits.GetCommitsByTag(tagOptionValue);
|
||||
dataAccess.WriteData(commits.CommitDetails);
|
||||
}
|
||||
break;
|
||||
case "xlsx":
|
||||
ExcelDataService excelDataService = new ExcelDataService();
|
||||
DataAccess dataAccessExcelCase = new DataAccess(excelDataService);
|
||||
|
||||
if (branchOptionValue != null && tagOptionValue != null) {
|
||||
Console.WriteLine("Please specify either a branch or a tag.");
|
||||
Environment.Exit(2);
|
||||
} else if (branchOptionValue != null && tagOptionValue == null) {
|
||||
switch (branchOptionValue)
|
||||
{
|
||||
case null:
|
||||
commits.GetCurrentCommitsByName();
|
||||
dataAccessExcelCase.WriteData(commits.CommitDetails);
|
||||
break;
|
||||
default:
|
||||
commits.GetCommitsByBranch(branchOptionValue);
|
||||
dataAccessExcelCase.WriteData(commits.CommitDetails);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
} else if (branchOptionValue == null && tagOptionValue != null) {
|
||||
commits.GetCommitsByTag(tagOptionValue);
|
||||
dataAccessExcelCase.WriteData(commits.CommitDetails);
|
||||
}
|
||||
break;
|
||||
case "pdf":
|
||||
PdfDataService pdfDataService = new PdfDataService();
|
||||
DataAccess dataAccessPdfCase = new DataAccess(pdfDataService);
|
||||
|
||||
switch (branchOptionValue)
|
||||
{
|
||||
case null:
|
||||
commits.GetCurrentCommitsByName();
|
||||
dataAccessPdfCase.WriteData(commits.CommitDetails);
|
||||
break;
|
||||
default:
|
||||
commits.GetCommitsByBranch(branchOptionValue);
|
||||
dataAccessPdfCase.WriteData(commits.CommitDetails);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case null:
|
||||
StdOutDataService stdOutDataService = new StdOutDataService();
|
||||
DataAccess dataAccessNullCase = new DataAccess(stdOutDataService);
|
||||
|
||||
if (branchOptionValue != null && tagOptionValue != null) {
|
||||
Console.WriteLine("Please specify either a branch or a tag.");
|
||||
Environment.Exit(2);
|
||||
} else if (branchOptionValue != null && tagOptionValue == null) {
|
||||
switch (branchOptionValue)
|
||||
{
|
||||
case null:
|
||||
commits.GetCurrentCommitsByName();
|
||||
dataAccessNullCase.WriteData(commits.CommitDetails);
|
||||
break;
|
||||
default:
|
||||
commits.GetCommitsByBranch(branchOptionValue);
|
||||
dataAccessNullCase.WriteData(commits.CommitDetails);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
} else if (branchOptionValue == null && tagOptionValue != null) {
|
||||
commits.GetCommitsByTag(tagOptionValue);
|
||||
dataAccessNullCase.WriteData(commits.CommitDetails);
|
||||
} else {
|
||||
Console.WriteLine("Please specify either a branch or a tag");
|
||||
Environment.Exit(2);
|
||||
}
|
||||
else if (branchOptionValue != null && tagOptionValue == null)
|
||||
{
|
||||
switch (branchOptionValue)
|
||||
{
|
||||
case null:
|
||||
commits.GetCurrentCommitsByName();
|
||||
dataAccessNullCase.WriteData(commits.CommitDetails);
|
||||
}
|
||||
dataAccess.WriteData(commits.CommitDetails);
|
||||
break;
|
||||
default:
|
||||
commits.GetCommitsByBranch(branchOptionValue);
|
||||
dataAccess.WriteData(commits.CommitDetails);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (branchOptionValue == null && tagOptionValue != null)
|
||||
{
|
||||
commits.GetCommitsByTag(tagOptionValue);
|
||||
dataAccess.WriteData(commits.CommitDetails);
|
||||
}
|
||||
break;
|
||||
case "xlsx":
|
||||
ExcelDataService excelDataService = new ExcelDataService();
|
||||
DataAccess dataAccessExcelCase = new DataAccess(excelDataService);
|
||||
|
||||
if (branchOptionValue != null && tagOptionValue != null)
|
||||
{
|
||||
Console.WriteLine("Please specify either a branch or a tag.");
|
||||
Environment.Exit(2);
|
||||
}
|
||||
else if (branchOptionValue != null && tagOptionValue == null)
|
||||
{
|
||||
switch (branchOptionValue)
|
||||
{
|
||||
case null:
|
||||
commits.GetCurrentCommitsByName();
|
||||
dataAccessExcelCase.WriteData(commits.CommitDetails);
|
||||
break;
|
||||
default:
|
||||
commits.GetCommitsByBranch(branchOptionValue);
|
||||
dataAccessExcelCase.WriteData(commits.CommitDetails);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (branchOptionValue == null && tagOptionValue != null)
|
||||
{
|
||||
commits.GetCommitsByTag(tagOptionValue);
|
||||
dataAccessExcelCase.WriteData(commits.CommitDetails);
|
||||
}
|
||||
break;
|
||||
case "pdf":
|
||||
PdfDataService pdfDataService = new PdfDataService();
|
||||
DataAccess dataAccessPdfCase = new DataAccess(pdfDataService);
|
||||
|
||||
switch (branchOptionValue)
|
||||
{
|
||||
case null:
|
||||
commits.GetCurrentCommitsByName();
|
||||
dataAccessPdfCase.WriteData(commits.CommitDetails);
|
||||
break;
|
||||
default:
|
||||
System.Console.WriteLine("This should not happen...");
|
||||
Environment.Exit(4);
|
||||
commits.GetCommitsByBranch(branchOptionValue);
|
||||
dataAccessPdfCase.WriteData(commits.CommitDetails);
|
||||
break;
|
||||
}
|
||||
},
|
||||
outputOption, branchOption, tagOption);
|
||||
break;
|
||||
case null:
|
||||
StdOutDataService stdOutDataService = new StdOutDataService();
|
||||
DataAccess dataAccessNullCase = new DataAccess(stdOutDataService);
|
||||
|
||||
if (branchOptionValue != null && tagOptionValue != null)
|
||||
{
|
||||
Console.WriteLine("Please specify either a branch or a tag.");
|
||||
Environment.Exit(2);
|
||||
}
|
||||
else if (branchOptionValue != null && tagOptionValue == null)
|
||||
{
|
||||
switch (branchOptionValue)
|
||||
{
|
||||
case null:
|
||||
commits.GetCurrentCommitsByName();
|
||||
dataAccessNullCase.WriteData(commits.CommitDetails);
|
||||
break;
|
||||
default:
|
||||
commits.GetCommitsByBranch(branchOptionValue);
|
||||
dataAccessNullCase.WriteData(commits.CommitDetails);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (branchOptionValue == null && tagOptionValue != null)
|
||||
{
|
||||
commits.GetCommitsByTag(tagOptionValue);
|
||||
dataAccessNullCase.WriteData(commits.CommitDetails);
|
||||
}
|
||||
else
|
||||
{
|
||||
commits.GetCurrentCommitsByName();
|
||||
dataAccessNullCase.WriteData(commits.CommitDetails);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
System.Console.WriteLine("This should not happen...");
|
||||
Environment.Exit(4);
|
||||
break;
|
||||
}
|
||||
},
|
||||
outputOption, branchOption, tagOption, dirOption);
|
||||
|
||||
rootCommand.Invoke(args);
|
||||
}
|
||||
|
Reference in New Issue
Block a user