using McMaster.Extensions.CommandLineUtils; using System; using System.IO; using System.Reflection; namespace UsmToolkit { [Command("UsmToolkit")] [VersionOptionFromMember("--version", MemberName = nameof(GetVersion))] [Subcommand(typeof(ExtractCommand), typeof(ConvertCommand), typeof(GetDependenciesCommand))] class Program { static int Main(string[] args) { try { return CommandLineApplication.Execute(args); } catch (FileNotFoundException e) { Console.WriteLine($"The file {e.FileName} cannot be found. The program will now exit."); return 2; } catch (Exception e) { Console.WriteLine($"FATAL ERROR: {e.Message}\n{e.StackTrace}"); return -1; } } protected int OnExecute(CommandLineApplication app) { app.ShowHelp(); return 1; } private static string GetVersion() => typeof(Program).Assembly.GetCustomAttribute().InformationalVersion; } }