2024-04-24 18:53:10 -04:00
|
|
|
|
using System;
|
2025-10-06 09:32:01 -04:00
|
|
|
|
using System.Collections.Generic;
|
2025-10-07 10:20:57 -04:00
|
|
|
|
using InfoPrint.Features;
|
2025-10-06 09:32:01 -04:00
|
|
|
|
using SabreTools.CommandLine;
|
2025-10-07 10:20:57 -04:00
|
|
|
|
using SabreTools.CommandLine.Features;
|
2024-04-02 11:56:27 -04:00
|
|
|
|
|
2024-11-04 12:14:28 -05:00
|
|
|
|
namespace InfoPrint
|
2024-04-02 11:56:27 -04:00
|
|
|
|
{
|
2024-04-24 18:53:10 -04:00
|
|
|
|
public static class Program
|
2024-04-02 11:56:27 -04:00
|
|
|
|
{
|
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
|
{
|
2025-10-06 09:32:01 -04:00
|
|
|
|
// Create the command set
|
2025-10-07 10:20:57 -04:00
|
|
|
|
var mainFeature = new MainFeature();
|
|
|
|
|
|
var commandSet = CreateCommands(mainFeature);
|
2025-10-06 09:32:01 -04:00
|
|
|
|
|
|
|
|
|
|
// If we have no args, show the help and quit
|
2026-01-25 14:30:18 -05:00
|
|
|
|
if (args is null || args.Length == 0)
|
2025-10-06 09:32:01 -04:00
|
|
|
|
{
|
|
|
|
|
|
commandSet.OutputAllHelp();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-07 10:20:57 -04:00
|
|
|
|
// Cache the first argument and starting index
|
|
|
|
|
|
string featureName = args[0];
|
2025-10-06 09:32:01 -04:00
|
|
|
|
|
2025-10-07 10:20:57 -04:00
|
|
|
|
// Try processing the standalone arguments
|
|
|
|
|
|
var topLevel = commandSet.GetTopLevel(featureName);
|
|
|
|
|
|
switch (topLevel)
|
2024-04-24 18:53:10 -04:00
|
|
|
|
{
|
2025-10-07 10:20:57 -04:00
|
|
|
|
// Standalone Options
|
|
|
|
|
|
case Help help: help.ProcessArgs(args, 0, commandSet); return;
|
|
|
|
|
|
|
|
|
|
|
|
// Default Behavior
|
|
|
|
|
|
default:
|
|
|
|
|
|
if (!mainFeature.ProcessArgs(args, 0))
|
|
|
|
|
|
{
|
|
|
|
|
|
commandSet.OutputAllHelp();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (!mainFeature.VerifyInputs())
|
|
|
|
|
|
{
|
|
|
|
|
|
Console.Error.WriteLine("At least one input is required");
|
|
|
|
|
|
commandSet.OutputAllHelp();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mainFeature.Execute();
|
|
|
|
|
|
break;
|
2024-04-24 18:53:10 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-06 09:32:01 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create the command set for the program
|
|
|
|
|
|
/// </summary>
|
2025-10-07 10:20:57 -04:00
|
|
|
|
private static CommandSet CreateCommands(MainFeature mainFeature)
|
2025-10-06 09:32:01 -04:00
|
|
|
|
{
|
|
|
|
|
|
List<string> header = [
|
|
|
|
|
|
"Information Printing Program",
|
|
|
|
|
|
string.Empty,
|
|
|
|
|
|
"InfoPrint <options> file|directory ...",
|
|
|
|
|
|
string.Empty,
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
var commandSet = new CommandSet(header);
|
|
|
|
|
|
|
2025-10-07 10:20:57 -04:00
|
|
|
|
commandSet.Add(new Help(["-?", "-h", "--help"]));
|
|
|
|
|
|
commandSet.Add(mainFeature.DebugInput);
|
|
|
|
|
|
commandSet.Add(mainFeature.HashInput);
|
|
|
|
|
|
commandSet.Add(mainFeature.FileOnlyInput);
|
2025-10-06 09:32:01 -04:00
|
|
|
|
#if NETCOREAPP
|
2025-10-07 10:20:57 -04:00
|
|
|
|
commandSet.Add(mainFeature.JsonInput);
|
2025-10-06 09:32:01 -04:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
return commandSet;
|
|
|
|
|
|
}
|
2024-04-02 11:56:27 -04:00
|
|
|
|
}
|
2025-07-24 09:31:28 -04:00
|
|
|
|
}
|