move console runner to named file and clean output then run in action

This commit is contained in:
Eliot Jones 2022-01-11 11:27:50 +00:00
parent 16e1e5e52d
commit 7ed985a023
5 changed files with 34 additions and 6 deletions

View File

@ -47,5 +47,5 @@ jobs:
- name: Unzip archives
run: sudo apt-get install p7zip-full && cd archive && 7z x part1-archive.7z && 7z x part2-archive.7z
- name: List Unzipped
run: ls archive
- name: Run tests
run: dotnet run --project tools/UglyToad.PdfPig.ConsoleRunner/UglyToad.PdfPig.ConsoleRunner.csproj "archive/"

View File

@ -11,7 +11,7 @@ namespace UglyToad.PdfPig.ConsoleRunner
{
if (args.Length == 0)
{
Console.WriteLine("At least 1 argument, path to test file directory, may be provided.");
Console.WriteLine("At least 1 argument, path to test file directory, must be provided.");
return 7;
}
@ -32,9 +32,13 @@ namespace UglyToad.PdfPig.ConsoleRunner
var hasError = false;
var errorBuilder = new StringBuilder();
var fileList = Directory.GetFiles(path, "*.pdf");
var fileList = Directory.GetFiles(path, "*.pdf", SearchOption.AllDirectories);
var runningCount = 0;
Console.WriteLine($"Found {fileList.Length} files.");
Console.WriteLine($"{GetCleanFilename("File")}| Size\t| Words\t| Pages");
foreach (var file in fileList)
{
if (maxCount.HasValue && runningCount >= maxCount)
@ -61,7 +65,11 @@ namespace UglyToad.PdfPig.ConsoleRunner
}
}
Console.WriteLine($"Read {numWords} words on {numPages} pages in document {file}.");
var filename = Path.GetFileName(file);
var size = new FileInfo(file);
Console.WriteLine($"{GetCleanFilename(filename)}| {size.Length}\t| {numWords}\t| {numPages}");
}
catch (Exception ex)
{
@ -84,5 +92,17 @@ namespace UglyToad.PdfPig.ConsoleRunner
return 0;
}
private static string GetCleanFilename(string name, int maxLength = 30)
{
if (name.Length <= maxLength)
{
var fillLength = maxLength - name.Length;
return name + new string(' ', fillLength);
}
return name.Substring(0, maxLength);
}
}
}

View File

@ -0,0 +1,8 @@
{
"profiles": {
"UglyToad.PdfPig.ConsoleRunner": {
"commandName": "Project",
"commandLineArgs": "\"C:\\temp\\pdfs\\archive\""
}
}
}