Пример #1
0
 private static int Main(string[] args)
 {
     Console.WriteLine(ProgramInfo.Greeting);
     if (args.NeedsHelp())
     {
         PrintUsage();
         return(ErrorCodes.MissingUserInput);
     }
     try
     {
         var arguments = args.To <MergeArgs>();
         Logger.Level = arguments.L;
         var source  = RecipeSource.FromFileOrInput(arguments.Recipe);
         var recipe  = new RecipeParser(source).Recipe;
         var options = TransformOptionsProvider.GetTransformOptions();
         recipe.Compile()(new ConfigTransformer(source.BasePath, options));
         return(ErrorCodes.Ok);
     }
     catch (RecipeCompilerException ex)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine(ex.Message);
         Console.ResetColor();
         return(ErrorCodes.RecipeError);
     }
     catch (Exception ex)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine($"{ProgramInfo.Name}: error: {ex.Message}");
         Console.WriteLine(ex.StackTrace);
         Console.ResetColor();
         return(ErrorCodes.Unhandled);
     }
 }
Пример #2
0
        public static void Merge(string recipe, LogLevel logLevel = LogLevel.Normal)
        {
            Logger.Level = logLevel;
            var source        = RecipeSource.FromFileOrInput(recipe);
            var recipeExpress = new RecipeParser(source).Recipe;
            var options       = TransformOptionsProvider.GetTransformOptions();

            recipeExpress.Compile()(new ConfigTransformer(source.BasePath, options));
        }