/// <summary> /// Runs the specified directory. /// </summary> /// <param name="directory">The directory.</param> /// <param name="pattern">The pattern.</param> /// <param name="generatorOptions">The generator options.</param> /// <returns> /// A list of output names. /// </returns> public static async Task <ConcurrentBag <string> > RunAsync(string directory, string pattern, GeneratorOptions?generatorOptions = null) { generatorOptions ??= GeneratorOptions.Default; using var progressReporter = new ProgressReporterFactory().Create(generatorOptions.ProgressReporter, generatorOptions.ProgressTextWriter); try { progressReporter.Start(); directory = string.IsNullOrEmpty(directory) ? Environment.CurrentDirectory : Path.IsPathRooted(directory) ? directory : Path.Combine(Environment.CurrentDirectory, directory); var searchPattern = string.IsNullOrEmpty(pattern) ? "*.gs.json" : pattern; var generatorDiscoverer = new SetupDiscoverer(new SetupFileFinder(), new JsonSetupProvider()); var setupInfos = await generatorDiscoverer.DiscoverAsync(directory, searchPattern).ConfigureAwait(false); var generatorRunnerFactory = new GeneratorRunnerFactory(); var generatorRunner = generatorRunnerFactory.Create(setupInfos); return(await generatorRunner.GenerateAsync(generatorOptions, new ProgressTracker <Report>(progressReporter)).ConfigureAwait(false)); } catch (Exception) { progressReporter.Stop(); throw; } }
public static void MainEntry(ProgressReporterFactory zProgressReporterFactory, string[] args) { var commandLineProcessor = new CommandLineProcessor( new CommandLineParser().Parse(args), zProgressReporterFactory) { CommandLineUtil = new CommandLineUtil() }; if (!commandLineProcessor.Process()) { #if !MONO_BUILD Win32.ShowConsole(Application.ExecutablePath, false); #endif Application.Run(new CardMakerMDI()); } }
/// <summary> /// Runs the asynchronous. /// </summary> /// <param name="setupsFactory">The setups factory.</param> /// <param name="generatorOptions">The generator options.</param> /// <returns> /// A list of output names. /// </returns> public static async Task <ConcurrentBag <string> > RunAsync(ISetupsFactory setupsFactory, GeneratorOptions?generatorOptions = null) { generatorOptions ??= GeneratorOptions.Default; using var progressReporter = new ProgressReporterFactory().Create(generatorOptions.ProgressReporter, generatorOptions.ProgressTextWriter); try { progressReporter.Start(); var generatorRunnerFactory = new GeneratorRunnerFactory(); var generatorRunner = generatorRunnerFactory.Create((await setupsFactory.GetSetupsAsync().ConfigureAwait(false)) .Select(x => new SetupInfo(setupsFactory.GetType().ToString(), x))); return(await generatorRunner.GenerateAsync(generatorOptions, new ProgressTracker <Report>(progressReporter)).ConfigureAwait(false)); } catch (Exception) { progressReporter.Stop(); throw; } }
/// <summary> /// /// </summary> /// <param name="zCommandLineParser">The parser to use within this processor</param> public CommandLineProcessor(CommandLineParser zCommandLineParser, ProgressReporterFactory zProgressReporterFactory) { m_zCommandLineParser = zCommandLineParser; m_zProgressReporterFactory = zProgressReporterFactory; }