Serilog
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
using CliWrap;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Phares.Shared;
|
||||
using Serilog;
|
||||
using ShellProgressBar;
|
||||
using System.Text;
|
||||
using View_by_Distance.Metadata.Models;
|
||||
@ -31,7 +31,7 @@ public class Rename
|
||||
private readonly IConfigurationRoot _ConfigurationRoot;
|
||||
private readonly Property.Models.Configuration _PropertyConfiguration;
|
||||
|
||||
public Rename(List<string> args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
|
||||
public Rename(List<string> args, ILogger<Program>? logger, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
|
||||
{
|
||||
if (isSilent)
|
||||
{ }
|
||||
@ -41,15 +41,14 @@ public class Rename
|
||||
_IsEnvironment = isEnvironment;
|
||||
_WorkingDirectory = workingDirectory;
|
||||
_ConfigurationRoot = configurationRoot;
|
||||
ILogger? log = Log.ForContext<Rename>();
|
||||
Property.Models.Configuration propertyConfiguration = Property.Models.Binder.Configuration.Get(isEnvironment, configurationRoot);
|
||||
Configuration configuration = Models.Binder.Configuration.Get(isEnvironment, configurationRoot, propertyConfiguration);
|
||||
_PropertyConfiguration = propertyConfiguration;
|
||||
_Configuration = configuration;
|
||||
log.Information(propertyConfiguration.RootDirectory);
|
||||
logger?.LogInformation(propertyConfiguration.RootDirectory);
|
||||
Property.Models.Configuration.Verify(propertyConfiguration, requireExist: false);
|
||||
Verify();
|
||||
List<string> lines = RenameFilesInDirectories(log);
|
||||
List<string> lines = RenameFilesInDirectories(logger);
|
||||
if (lines.Any())
|
||||
{
|
||||
File.WriteAllLines($"D:/Tmp/Phares/{DateTime.Now.Ticks}.tsv", lines);
|
||||
@ -73,7 +72,7 @@ public class Rename
|
||||
throw new NullReferenceException(nameof(_PropertyConfiguration));
|
||||
}
|
||||
|
||||
private List<string> RenameFilesInDirectories(ILogger log)
|
||||
private List<string> RenameFilesInDirectories(ILogger? logger)
|
||||
{
|
||||
List<string> results = new();
|
||||
string message;
|
||||
@ -159,24 +158,24 @@ public class Rename
|
||||
File.WriteAllText($"{to}.paddedId", $"{to}{Environment.NewLine}{fileHolder.FullName}");
|
||||
}
|
||||
ConsoleKey? consoleKey = null;
|
||||
log.Information($"Ready to Move {verifiedToDoCollection.Count} files[i](s)?");
|
||||
logger?.LogInformation($"Ready to Move {verifiedToDoCollection.Count} files[i](s)?");
|
||||
for (int y = 0; y < int.MaxValue; y++)
|
||||
{
|
||||
log.Information("Press \"Y\" key to move files[i](s), \"N\" key to log files[i](s) or close console to not move files");
|
||||
logger?.LogInformation("Press \"Y\" key to move files[i](s), \"N\" key to log files[i](s) or close console to not move files");
|
||||
consoleKey = System.Console.ReadKey().Key;
|
||||
if (consoleKey is ConsoleKey.Y or ConsoleKey.N)
|
||||
break;
|
||||
}
|
||||
log.Information(". . .");
|
||||
logger?.LogInformation(". . .");
|
||||
if (consoleKey is null || consoleKey.Value != ConsoleKey.Y)
|
||||
log.Information("Nothing moved!");
|
||||
logger?.LogInformation("Nothing moved!");
|
||||
else
|
||||
{
|
||||
message = ") Renaming files";
|
||||
progressBar = new(count, message, options);
|
||||
results.AddRange(Move(progressBar, verifiedToDoCollection));
|
||||
progressBar.Dispose();
|
||||
log.Information("Done Moving");
|
||||
logger?.LogInformation("Done Moving");
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
Reference in New Issue
Block a user