Address comments

This commit is contained in:
Mbucari 2023-07-03 09:58:53 -06:00
parent db2b10d2a4
commit 86124fc609
8 changed files with 30 additions and 40 deletions

View File

@ -43,21 +43,6 @@ namespace AppScaffolding
public static ReleaseIdentifier ReleaseIdentifier { get; private set; } public static ReleaseIdentifier ReleaseIdentifier { get; private set; }
public static Variety Variety { 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 // AppScaffolding
private static Assembly _executingAssembly; private static Assembly _executingAssembly;
private static Assembly ExecutingAssembly private static Assembly ExecutingAssembly
@ -111,6 +96,22 @@ namespace AppScaffolding
configureLogging(config); configureLogging(config);
logStartupState(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 // all else should occur after logging
wireUpSystemEvents(config); wireUpSystemEvents(config);

View File

@ -48,12 +48,6 @@ namespace LibationAvalonia
var classicLifetimeTask = Task.Run(() => new ClassicDesktopStyleApplicationLifetime()); var classicLifetimeTask = Task.Run(() => new ClassicDesktopStyleApplicationLifetime());
var appBuilderTask = Task.Run(BuildAvaloniaApp); var appBuilderTask = Task.Run(BuildAvaloniaApp);
LibationScaffolding.SetReleaseIdentifier(Variety.Chardonnay);
if (LibationScaffolding.ReleaseIdentifier is ReleaseIdentifier.None)
return;
if (config.LibationSettingsAreValid) if (config.LibationSettingsAreValid)
{ {
if (!RunDbMigrations(config)) if (!RunDbMigrations(config))
@ -81,7 +75,7 @@ namespace LibationAvalonia
LibationScaffolding.RunPostConfigMigrations(config); LibationScaffolding.RunPostConfigMigrations(config);
LibationScaffolding.RunPostMigrationScaffolding(config); LibationScaffolding.RunPostMigrationScaffolding(config);
return true; return LibationScaffolding.ReleaseIdentifier is not ReleaseIdentifier.None;
} }
catch (Exception exDebug) catch (Exception exDebug)
{ {

View File

@ -27,13 +27,13 @@ namespace LibationCli
} }
*/ */
#endregion #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; } 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; } 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; } public bool json { get; set; }
protected override Task ProcessAsync() protected override Task ProcessAsync()

View File

@ -11,6 +11,9 @@ namespace LibationCli.Options;
[Verb("search", HelpText = "Search for books in your library")] [Verb("search", HelpText = "Search for books in your library")]
internal class SearchOptions : OptionsBase 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")] [Value(0, MetaName = "query", Required = true, HelpText = "Lucene search string")]
public IEnumerable<string> Query { get; set; } public IEnumerable<string> Query { get; set; }
@ -21,15 +24,13 @@ internal class SearchOptions : OptionsBase
Console.WriteLine($"Found {results.Count} matching results."); Console.WriteLine($"Found {results.Count} matching results.");
const int numResults = 10; string nextPrompt = "Press any key for the next " + NumResultsPerPage + " results or Esc for all results";
string nextPrompt = "Press any key for the next " + numResults + " results or Esc for all results";
bool waitForNextBatch = true; 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(); 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)); sb.AppendLine(getDocDisplay(results[j].Doc));
Console.Write(sb.ToString()); Console.Write(sb.ToString());

View File

@ -14,6 +14,7 @@ namespace LibationCli
""")] """)]
public class SetDownloadStatusOptions : OptionsBase 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'")] [Option(shortName: 'd', longName: "downloaded", Group = "Download Status", HelpText = "set download status to 'Downloaded'")]
public bool SetDownloaded { get; set; } public bool SetDownloaded { get; set; }

View File

@ -10,11 +10,6 @@ namespace LibationCli
{ {
public static void Initialize() 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 // // do not use Configuration before this line //

View File

@ -127,10 +127,10 @@ namespace LibationFileManager
var regex = GetBookSearchRegex(productId); var regex = GetBookSearchRegex(productId);
//Find all extant files matching the priductID //Find all extant files matching the productId
//using both the file system and the file path cache //using both the file system and the file path cache
return return
FilePathCache FilePathCache
.GetFiles(productId) .GetFiles(productId)
.Where(c => c.fileType == FileType.Audio && File.Exists(c.path)) .Where(c => c.fileType == FileType.Audio && File.Exists(c.path))
.Select(c => c.path) .Select(c => c.path)

View File

@ -30,8 +30,6 @@ namespace LibationWinForms
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
AppScaffolding.LibationScaffolding.SetReleaseIdentifier(AppScaffolding.Variety.Classic);
//***********************************************// //***********************************************//
// // // //
// do not use Configuration before this line // // do not use Configuration before this line //