static void Main(string[] args) { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; var options = new CommandLineOptions(); if (Parser.Default.ParseArgumentsStrict(args, options) && ValidateOptions(options)) { new Program().Run(options); } }
private static bool ValidateOptions(CommandLineOptions options) { if (string.IsNullOrEmpty(options.Namespace)) { Console.WriteLine("Please provide a valid namespace. It cannot be empty."); return false; } if (string.IsNullOrEmpty(options.SourcePackage) || !File.Exists(options.SourcePackage)) { Console.WriteLine("Unable to find a source package at {0}.", options.SourcePackage); return false; } try { Directory.CreateDirectory(Path.Combine(options.OutputDirectory)); } catch (Exception ex) { Console.WriteLine("Unable to locate or create the output directory [{0}].", ex.Message); return false; } // We won't bother with error messages here, just treat empty values as default. if (string.IsNullOrEmpty(options.PageBaseClass)) { options.PageBaseClass = ComposerMigrationOptions.Default.PageBaseClass; } if (string.IsNullOrEmpty(options.BlockBaseClass)) { options.PageBaseClass = ComposerMigrationOptions.Default.BlockBaseClass; } return true; }
private static void ConfigureContainer(CommandLineOptions options) { ContainerBootstrapper.Bootstrap(); ObjectFactory.Inject<IComposerTranformationOptions>(options); ObjectFactory.Inject<ICodeGenerationOptions>(options); }
private void Run(CommandLineOptions options) { InitalizeLogger(options.Verbose ? LogLevel.Debug : LogLevel.Info); ConfigureContainer(options); var logger = LogManager.GetCurrentClassLogger(); logger.InfoFormat("Generating classes from '{0}' and saving output to '{1}'", options.SourcePackage, options.OutputDirectory); var packageReader = ObjectFactory.GetInstance<ImportPackageReader>(); Generate(packageReader, options.SourcePackage, options.OutputDirectory); }