diff --git a/Source/AppScaffolding/LibationScaffolding.cs b/Source/AppScaffolding/LibationScaffolding.cs index e474191f..31886b89 100644 --- a/Source/AppScaffolding/LibationScaffolding.cs +++ b/Source/AppScaffolding/LibationScaffolding.cs @@ -43,21 +43,6 @@ namespace AppScaffolding public static ReleaseIdentifier ReleaseIdentifier { get; private set; } public static Variety Variety { get; private set; } - public static void SetReleaseIdentifier(Variety varietyType) - { - Variety = Enum.IsDefined(varietyType) ? varietyType : Variety.None; - - var releaseID = (ReleaseIdentifier)((int)varietyType | (int)Configuration.OS | (int)RuntimeInformation.ProcessArchitecture); - - if (Enum.IsDefined(releaseID)) - ReleaseIdentifier = releaseID; - else - { - ReleaseIdentifier = ReleaseIdentifier.None; - Serilog.Log.Logger.Warning("Unknown release identifier @{DebugInfo}", new { Variety = varietyType, Configuration.OS, RuntimeInformation.ProcessArchitecture }); - } - } - // AppScaffolding private static Assembly _executingAssembly; private static Assembly ExecutingAssembly @@ -111,6 +96,22 @@ namespace AppScaffolding configureLogging(config); logStartupState(config); + #region Determine Libation Variery and Release ID + + Variety = File.Exists("System.Windows.Forms.dll") ? Variety.Classic : Variety.Chardonnay; + + var releaseID = (ReleaseIdentifier)((int)Variety | (int)Configuration.OS | (int)RuntimeInformation.ProcessArchitecture); + + if (Enum.IsDefined(releaseID)) + ReleaseIdentifier = releaseID; + else + { + ReleaseIdentifier = ReleaseIdentifier.None; + Serilog.Log.Logger.Warning("Unknown release identifier @{DebugInfo}", new { Variety, Configuration.OS, RuntimeInformation.ProcessArchitecture }); + } + + #endregion + // all else should occur after logging wireUpSystemEvents(config); diff --git a/Source/LibationAvalonia/Program.cs b/Source/LibationAvalonia/Program.cs index 5f2744b9..23f670a3 100644 --- a/Source/LibationAvalonia/Program.cs +++ b/Source/LibationAvalonia/Program.cs @@ -48,12 +48,6 @@ namespace LibationAvalonia var classicLifetimeTask = Task.Run(() => new ClassicDesktopStyleApplicationLifetime()); var appBuilderTask = Task.Run(BuildAvaloniaApp); - LibationScaffolding.SetReleaseIdentifier(Variety.Chardonnay); - - if (LibationScaffolding.ReleaseIdentifier is ReleaseIdentifier.None) - return; - - if (config.LibationSettingsAreValid) { if (!RunDbMigrations(config)) @@ -81,7 +75,7 @@ namespace LibationAvalonia LibationScaffolding.RunPostConfigMigrations(config); LibationScaffolding.RunPostMigrationScaffolding(config); - return true; + return LibationScaffolding.ReleaseIdentifier is not ReleaseIdentifier.None; } catch (Exception exDebug) { diff --git a/Source/LibationCli/Options/ExportOptions.cs b/Source/LibationCli/Options/ExportOptions.cs index 6e994718..e3cb3602 100644 --- a/Source/LibationCli/Options/ExportOptions.cs +++ b/Source/LibationCli/Options/ExportOptions.cs @@ -27,13 +27,13 @@ namespace LibationCli } */ #endregion - [Option(shortName: 'x', longName: "xlsx", HelpText = "Microsoft Excel Spreadsheet", SetName = "Export Format")] + [Option(shortName: 'x', longName: "xlsx", HelpText = "Microsoft Excel Spreadsheet", SetName = "xlsx")] public bool xlsx { get; set; } - [Option(shortName: 'c', longName: "csv", HelpText = "Comma-separated values", SetName = "Export Format")] + [Option(shortName: 'c', longName: "csv", HelpText = "Comma-separated values", SetName = "csv")] public bool csv { get; set; } - [Option(shortName: 'j', longName: "json", HelpText = "JavaScript Object Notation", SetName = "Export Format")] + [Option(shortName: 'j', longName: "json", HelpText = "JavaScript Object Notation", SetName = "json")] public bool json { get; set; } protected override Task ProcessAsync() diff --git a/Source/LibationCli/Options/SearchOptions.cs b/Source/LibationCli/Options/SearchOptions.cs index d17e95c2..2c1d1b6d 100644 --- a/Source/LibationCli/Options/SearchOptions.cs +++ b/Source/LibationCli/Options/SearchOptions.cs @@ -11,6 +11,9 @@ namespace LibationCli.Options; [Verb("search", HelpText = "Search for books in your library")] internal class SearchOptions : OptionsBase { + [Option('n', Default = 10, HelpText = "Number of search results per page")] + public int NumResultsPerPage { get; set; } + [Value(0, MetaName = "query", Required = true, HelpText = "Lucene search string")] public IEnumerable Query { get; set; } @@ -21,15 +24,13 @@ internal class SearchOptions : OptionsBase Console.WriteLine($"Found {results.Count} matching results."); - const int numResults = 10; - - string nextPrompt = "Press any key for the next " + numResults + " results or Esc for all results"; + string nextPrompt = "Press any key for the next " + NumResultsPerPage + " results or Esc for all results"; bool waitForNextBatch = true; - for (int i = 0; i < results.Count; i += numResults) + for (int i = 0; i < results.Count; i += NumResultsPerPage) { var sb = new StringBuilder(); - for (int j = i; j < int.Min(results.Count, i + numResults); j++) + for (int j = i; j < int.Min(results.Count, i + NumResultsPerPage); j++) sb.AppendLine(getDocDisplay(results[j].Doc)); Console.Write(sb.ToString()); diff --git a/Source/LibationCli/Options/SetDownloadStatusOptions.cs b/Source/LibationCli/Options/SetDownloadStatusOptions.cs index 615a54a1..4205542a 100644 --- a/Source/LibationCli/Options/SetDownloadStatusOptions.cs +++ b/Source/LibationCli/Options/SetDownloadStatusOptions.cs @@ -14,6 +14,7 @@ namespace LibationCli """)] public class SetDownloadStatusOptions : OptionsBase { + //https://github.com/commandlineparser/commandline/wiki/Option-Groups [Option(shortName: 'd', longName: "downloaded", Group = "Download Status", HelpText = "set download status to 'Downloaded'")] public bool SetDownloaded { get; set; } diff --git a/Source/LibationCli/Setup.cs b/Source/LibationCli/Setup.cs index 8c4f242e..5a071562 100644 --- a/Source/LibationCli/Setup.cs +++ b/Source/LibationCli/Setup.cs @@ -10,11 +10,6 @@ namespace LibationCli { public static void Initialize() { - //Determine variety by the dlls present in the current directory. - //Necessary to be able to check for upgrades. - var variety = System.IO.File.Exists("System.Windows.Forms.dll") ? Variety.Classic : Variety.Chardonnay; - LibationScaffolding.SetReleaseIdentifier(variety); - //***********************************************// // // // do not use Configuration before this line // diff --git a/Source/LibationFileManager/AudibleFileStorage.cs b/Source/LibationFileManager/AudibleFileStorage.cs index 34dc5b64..55157e92 100644 --- a/Source/LibationFileManager/AudibleFileStorage.cs +++ b/Source/LibationFileManager/AudibleFileStorage.cs @@ -127,10 +127,10 @@ namespace LibationFileManager var regex = GetBookSearchRegex(productId); - //Find all extant files matching the priductID - //using both the file system and the file path cache + //Find all extant files matching the productId + //using both the file system and the file path cache return - FilePathCache + FilePathCache .GetFiles(productId) .Where(c => c.fileType == FileType.Audio && File.Exists(c.path)) .Select(c => c.path) diff --git a/Source/LibationWinForms/Program.cs b/Source/LibationWinForms/Program.cs index c8462f83..43ec1dde 100644 --- a/Source/LibationWinForms/Program.cs +++ b/Source/LibationWinForms/Program.cs @@ -30,8 +30,6 @@ namespace LibationWinForms ApplicationConfiguration.Initialize(); - AppScaffolding.LibationScaffolding.SetReleaseIdentifier(AppScaffolding.Variety.Classic); - //***********************************************// // // // do not use Configuration before this line //