private bool IsCommand(string arg, IEnumerable <CommandItem> commands, out CommandItem commandFound) { commandFound = null; foreach (var command in commands) { if (arg.ToLower() == command.Name.ToLower()) { commandFound = command; return(true); } } return(false); }
public void Generate(CommandItem command, TextWriter output, string liquidTemplateText) { try { var template = Template.Parse(liquidTemplateText); var applicationDrop = ToDrop(_application); var commandDrop = ToDrop(command); var result = template.Render(Hash.FromAnonymousObject(new { application = applicationDrop, command = commandDrop })); result = result.Replace(Environment.NewLine, "").Replace(NewLine, Environment.NewLine); output.Write(result); } catch (DotLiquid.Exceptions.SyntaxException exception) { console.Out.WriteLine($"Syntax error in template [{liquidTemplateText}]: {exception.Message}"); } catch (Exception exception) { console.Out.WriteLine(exception.ToString()); } }
private ILiquidizable ToDrop(CommandItem command) { return(new CommandDrop(command)); }
public CommandDrop(string fullCommand, CommandItem x) { this.fullCommand = fullCommand; this.x = x; }
public CommandDrop(CommandItem x) { this.fullCommand = x.Name; this.x = x; }
internal void AddCommand(CommandItem result) { _commands.Add(result); }