Overhaul LibationCli
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
This commit is contained in:
parent
bb05847b25
commit
29803c6ba0
14 changed files with 477 additions and 146 deletions
52
Source/LibationCli/HelpVerb.cs
Normal file
52
Source/LibationCli/HelpVerb.cs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
using AppScaffolding;
|
||||
using CommandLine;
|
||||
using CommandLine.Text;
|
||||
|
||||
namespace LibationCli;
|
||||
|
||||
[Verb("help", HelpText = "Display more information on a specific command.")]
|
||||
internal class HelpVerb
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of the verb to get help about
|
||||
/// </summary>
|
||||
[Value(0, Default = "")]
|
||||
public string HelpType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a base <see cref="HelpText"/> for <see cref="LibationCli"/>
|
||||
/// </summary>
|
||||
public static HelpText CreateHelpText()
|
||||
{
|
||||
var auto = new HelpText
|
||||
{
|
||||
AutoVersion = false,
|
||||
AutoHelp = false,
|
||||
Heading = $"LibationCli v{LibationScaffolding.BuildVersion.ToString(3)}",
|
||||
AdditionalNewLineAfterOption = true,
|
||||
MaximumDisplayWidth = 80
|
||||
};
|
||||
return auto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the <see cref="HelpType"/>'s <see cref="HelpText"/>
|
||||
/// </summary>
|
||||
public HelpText GetHelpText()
|
||||
{
|
||||
var helpText = CreateHelpText();
|
||||
var result = new Parser().ParseArguments(new string[] { HelpType }, Program.VerbTypes);
|
||||
if (result.TypeInfo.Current == typeof(NullInstance))
|
||||
{
|
||||
//HelpType is not a defined verb so get LibationCli usage
|
||||
helpText.AddVerbs(Program.VerbTypes);
|
||||
}
|
||||
else
|
||||
{
|
||||
helpText.AddDashesToOption = true;
|
||||
helpText.AutoHelp = true;
|
||||
helpText.AddOptions(result);
|
||||
}
|
||||
return helpText;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue