public int OnExecute() { if (Profile == null) { Console.Error.WriteLine("You must specify a profile name for which to generate code"); return(-1); } var profile = GetProfiles().SingleOrDefault(x => x.Name == Profile); if (profile == null) { Console.Error.WriteLine($"Could not resolve profile] for name [{Profile}]"); return(-1); } var options = _serializer.Load(profile); Console.WriteLine("Got Options: " + options); var tc = ResolveTemplates(options); var model = _cacheBuilder.LoadFromCache(options); _codeGenerator.Generate(options, model, tc, File.WriteAllText); return(0); }
public void OnExecute() { using var server = OutProcGenProtocol.CreateServer(PipeName); server.WaitForConnection(); server.BeginSession(); // server.StartProfile("all_profiles"); // var buff = new StringBuilder(); // buff.AppendLine(@" //namespace Conjure.Gen //{ // public partial class Profiles // { //"); // foreach (var profile in GetProfiles()) // { // buff.AppendLine($" // {profile.Name}"); // buff.AppendLine($" public const string ProfilePath_{profile.Name} = \"{profile.ProfilePath.Replace("\\", "\\\\")}\";"); // buff.AppendLine($" public const string OptionsPath_{profile.Name} = \"{profile.OptionsPath.Replace("\\", "\\\\")}\";"); // } // buff.AppendLine(@" // } //} //"); // server.AddFile("AllProfiles.cs", buff.ToString()); try { foreach (var profile in GetProfiles()) { var options = _serializer.Load(profile); var model = _cacheBuilder.LoadFromCache(options); var tc = GenerateCommand.ResolveTemplates(options); server.StartProfile(profile.Name); _codeGenerator.Generate(options, model, tc, server.AddFile); } } catch (Exception ex) { server.Fail("???", ex.Message, ex.StackTrace); } server.EndSession(); }