Пример #1
0
 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);
 }
Пример #2
0
 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());
     }
 }
Пример #3
0
 private ILiquidizable ToDrop(CommandItem command)
 {
     return(new CommandDrop(command));
 }
Пример #4
0
 public CommandDrop(string fullCommand, CommandItem x)
 {
     this.fullCommand = fullCommand;
     this.x           = x;
 }
Пример #5
0
 public CommandDrop(CommandItem x)
 {
     this.fullCommand = x.Name;
     this.x           = x;
 }
Пример #6
0
 internal void AddCommand(CommandItem result)
 {
     _commands.Add(result);
 }