public static int Execute(string[] args, IConfiguration config) => Parser.Default.ParseArguments <RunOptions, AssembleOptions, DisassembleOptions, FormatOptions>(args).MapResult( (RunOptions opts) => RunCommand.Run(opts, _fileReader, _outputWriter, config), (AssembleOptions opts) => AssembleCommand.Run(opts, _fileReader, _fileWriter, config), (DisassembleOptions opts) => DisassembleCommand.Run(opts, _fileReader, _fileWriter, config), (FormatOptions opts) => FormatCommand.Run(opts, _fileReader, _fileWriter, config), errs => 1);
static int Main(string[] args) { if (args.Any(a => a == "--debug")) { args = args.Where(a => a != "--debug").ToArray(); Console.WriteLine($"Waiting for debugger to attach. Process ID: {System.Diagnostics.Process.GetCurrentProcess().Id}"); Console.WriteLine("Press ENTER to continue."); Console.ReadLine(); } var app = new CommandLineApplication(); app.Name = Name; app.FullName = "ILspect Command-Line Interface"; app.HelpOption("-h|-?|--help"); app.VersionOption("-v|--version", Program.Version); ListCommand.Register(app); GraphCommand.Register(app); DisassembleCommand.Register(app); SyntaxCommand.Register(app); CommandHelpers.RegisterHelpCommand(app); app.OnExecute(() => { app.ShowHelp(); return(0); }); try { return(app.Execute(args)); } catch (Exception ex) { CommandHelpers.Error(ex.Message); #if DEBUG CommandHelpers.Error(ex.ToString()); #endif return(-1); } }
public void Dasm_command_tests(string name) { // Arrange var content = _testSource.BinFiles[name]; var expected = _testSource.BinVrilFiles[name]; var options = new DisassembleOptions() { FilePath = name }; var reader = MockFactory.NewFileReader(content); var writer = MockFactory.NewFileWriter(); var configuration = MockFactory.NewConfiguration(); // Act DisassembleCommand.Run(options, reader, writer, configuration); // Assert var file = Assert.Single(writer.Files.Values); var actual = Assert.IsType <string>(file); Assert.Equal(expected, actual); }