static int Main(string[] argv) { var args = argv.ToList(); var ctx = new Context { Output = Console.Out }; var scriptPath = StringArg(args, "--script"); if (string.IsNullOrEmpty(scriptPath)) { Std.Error("script name/path must be supplied via the --script argument"); return(1); } try { string modelPath = args.FirstOrDefault(); if (string.IsNullOrEmpty(modelPath)) { Std.Error("Expected model file name/path to be supplied"); return(2); } args.RemoveAt(0); XDocument model = XDocument.Load(modelPath); var root = model.Root; root.Add(new XAttribute("model-path", modelPath)); root.Add(new XAttribute("script-path", scriptPath)); root.Add(new XAttribute("datetime-utc", DateTime.UtcNow.ToString("u"))); MergeArgsAsAttributes(args, root); // extra arguments AFTER the model file are added as attributes to the root element Scripts.Run(scriptPath, root, ctx); return(0); } catch (Exception ex) { Std.Error(ex.ToString()); return(9); } }
public override void Execute(XElement model, Context ctx) { var scriptPath = ExpandVars(_quoted, model, ctx); Scripts.Run(scriptPath, model, ctx); }