public static void Compile(TextReader input, TextWriter output) { TextWriter outputw; var schemaDocument = CommandSchema.Get(); dynamic schemaJson = JsonConvert.DeserializeObject(schemaDocument); var commandSchemaDocument = JsonConvert.SerializeObject( schemaJson.command); var schema = JSchema.Parse((string)commandSchemaDocument); var jsons = JToken.Parse(input.ReadToEnd()); IList <string> errorMessages; var isValid = jsons.IsValid(schema, out errorMessages); if (isValid == false) { throw new Exception(string.Join("\n", errorMessages.ToArray())); } foreach (var json in jsons) { CommandSourceBase src = new CommandSourceBase(); var source = new CommandSource(json); dynamic _json = json; string filename = src.ToStringHelper.ToStringWithCulture(_json.name).ToLower() + ".aml"; outputw = File.CreateText(filename); outputw.Write(source.TransformText()); outputw.Flush(); Console.WriteLine(" -> .\\{0}", filename); } }
public InvokeCommandSource(RootCommandSource root, CommandSourceBase parent) : base(new Command("invoke", ""), parent) { Command.Handler = CommandHandler.Create(() => { root.CurrentCommandSource = this; return(0); }); }
public ListCommandSource(RootCommandSource root, CommandSourceBase parent) : base(new Command("list", "List the elements you are interested in"), parent) { verbosityOption = Getverbosity(); Command.Add(verbosityOption); Command.Handler = CommandHandler.Create(() => { root.CurrentCommandSource = this; return(0); }); }
public FindCommandSource(RootCommandSource root, CommandSourceBase parent) : base(new Command("find", "Use this to find things"), parent) { intArgArgument = GetintArg(); Command.Add(intArgArgument); stringOptionOption = GetstringOption(); Command.Add(stringOptionOption); boolOptionOption = GetboolOption(); Command.Add(boolOptionOption); Command.Handler = CommandHandler.Create(() => { root.CurrentCommandSource = this; return(0); }); }
public CliRootCommandSource(RootCommandSource root, CommandSourceBase parent) : base(new Command("cli-root", "This is the entry point, the end user types the executable name"), parent) { StringPropertyOption = GetStringProperty(); Command.Add(StringPropertyOption); ctorParamOption = GetctorParam(); Command.Add(ctorParamOption); FindCommand = new FindCommandSource(this, this); Command.AddCommand(FindCommand.Command); ListCommand = new ListCommandSource(this, this); Command.AddCommand(ListCommand.Command); Command.Handler = CommandHandler.Create((InvocationContext context) => { CurrentCommandSource = this; CurrentParseResult = context.ParseResult; return(0); }); }
public FormatCommandSource(RootCommandSource root, CommandSourceBase parent) : base(new Command("format", "Formats source code."), parent) { folderOption = Getfolder(); Command.Add(folderOption); filesOption = Getfiles(); Command.Add(filesOption); excludeOption = Getexclude(); Command.Add(excludeOption); checkOption = Getcheck(); Command.Add(checkOption); reportOption = Getreport(); Command.Add(reportOption); verbosityOption = Getverbosity(); Command.Add(verbosityOption); Command.Handler = CommandHandler.Create((InvocationContext context) => { CurrentCommandSource = this; CurrentParseResult = context.ParseResult; return(0); }); }
public DotnetFormatCommandSource(RootCommandSource root, CommandSourceBase parent) : base(new Command("dotnet-format", ""), parent) { FolderOption = GetFolder(); Command.Add(FolderOption); FilesOption = GetFiles(); Command.Add(FilesOption); ExcludeOption = GetExclude(); Command.Add(ExcludeOption); CheckOption = GetCheck(); Command.Add(CheckOption); ReportOption = GetReport(); Command.Add(ReportOption); VerbosityOption = GetVerbosity(); Command.Add(VerbosityOption); InvokeCommand = new InvokeCommandSource(this, this); Command.AddCommand(InvokeCommand.Command); Command.Handler = CommandHandler.Create((InvocationContext context) => { CurrentCommandSource = this; CurrentParseResult = context.ParseResult; return(0); }); }