public static void ViewScript(string[] commandArgs) { var scriptfile = commandArgs[0]; Console.WriteLine(DynamicResponseCreatorBase.ExecuteIncludes(File.ReadAllText(scriptfile), Path.GetDirectoryName(scriptfile))); }
public static async Task MainAsync(string[] args, CancellationToken token) { WriteLine($"Netmockery v {NetmockeryVersion} ({FrameworkVersion})"); #if NET462 System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true); #endif ParsedCommandLine parsedArguments; try { parsedArguments = CommandLineParser.ParseArguments(args); } catch (CommandLineParsingException clpe) { Error.WriteLine($"ERROR: {clpe.Message}"); return; } if (!Directory.Exists(parsedArguments.EndpointCollectionDirectory)) { Error.WriteLine("Directory not found"); return; } var endpointCollection = EndpointCollectionReader.ReadFromDirectory(parsedArguments.EndpointCollectionDirectory); if (parsedArguments.Command != CommandLineParser.COMMAND_SERVICE) { SetUtf8OutputEncodingIfOutputIsRedirected(); } switch (parsedArguments.Command) { case CommandLineParser.COMMAND_NORMAL: if (endpointCollection.Endpoints.Count() == 0) { Error.WriteLine("No endpoints found"); return; } WriteLine("Admin interface available on /__netmockery"); Startup.TestMode = parsedArguments.TestMode; CreateWebHost(parsedArguments.EndpointCollectionDirectory, Directory.GetCurrentDirectory(), parsedArguments.Url).Run(); break; case CommandLineParser.COMMAND_SERVICE: RunAsService(parsedArguments); break; case CommandLineParser.COMMAND_TEST: await TestAsync(parsedArguments, endpointCollection); break; case CommandLineParser.COMMAND_DUMP: Dump(endpointCollection); break; case CommandLineParser.COMMAND_DUMPREFS: foreach (var metadataReference in DynamicResponseCreatorBase.GetDefaultMetadataReferences()) { Console.WriteLine(metadataReference.Display); } break; } }