Add version verb with option to check for upgrade Add Search verb to search the library Add export file type inference Add more set-status options Add console progress bar and ETA Add processable option to liberate specific book IDs Scan accounts by nickname or account ID Improve startup performance for halp and on parsing error More useful error messages
60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
using AppScaffolding;
|
|
using CommandLine;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LibationCli.Options;
|
|
|
|
[Verb("version", HelpText = "Display version information.")]
|
|
internal class VersionOptions : OptionsBase
|
|
{
|
|
[Option('c', "check", Required = false, HelpText = "Check if an upgrade is available")]
|
|
public bool CheckForUpgrade { get; set; }
|
|
|
|
protected override Task ProcessAsync()
|
|
{
|
|
const string checkingForUpgrade = "Checking for upgrade...";
|
|
Console.WriteLine($"Libation {LibationScaffolding.Variety} v{LibationScaffolding.BuildVersion.ToString(3)}");
|
|
|
|
if (CheckForUpgrade)
|
|
{
|
|
Console.Write(checkingForUpgrade);
|
|
|
|
var origColor = Console.ForegroundColor;
|
|
try
|
|
{
|
|
var upgradeProperties = LibationScaffolding.GetLatestRelease();
|
|
|
|
if (upgradeProperties is null)
|
|
{
|
|
Console.ForegroundColor = ConsoleColor.Green;
|
|
ReplaceConsoleText(Console.Out, checkingForUpgrade.Length, "No available upgrade");
|
|
Console.WriteLine();
|
|
}
|
|
else
|
|
{
|
|
Console.ForegroundColor = ConsoleColor.Red;
|
|
ReplaceConsoleText(Console.Out, checkingForUpgrade.Length, $"Upgrade Available: v{upgradeProperties.LatestRelease.ToString(3)}");
|
|
Console.WriteLine();
|
|
Console.WriteLine();
|
|
Console.WriteLine(upgradeProperties.ZipUrl);
|
|
Console.WriteLine();
|
|
Console.WriteLine("Release Notes");
|
|
Console.WriteLine("=============");
|
|
Console.WriteLine(upgradeProperties.Notes);
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
Console.Error.WriteLine("ERROR CHECKING FOR UPGRADE");
|
|
}
|
|
finally
|
|
{
|
|
Console.ForegroundColor = origColor;
|
|
}
|
|
}
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|