public BaseCommandHandlerParameter Parse(string name, string definition)
 {
     try
     {
         if (!definition.Contains("=>"))
             return new BaseCommandHandlerParameter(name, definition);
         var chunks = definition.Split(new string[] { "=>" }, StringSplitOptions.None);
         var parameters = new BaseCommandHandlerParameter(name, chunks[0]);
         BaseCommandHandlerParameter parameter = parameters;
         chunks[1]
             .Split(new string[] { "||" }, StringSplitOptions.None).ToList()
             .ForEach(x =>
                 {
                     var y =x.Split(new string[] { "|" }, StringSplitOptions.None);
                     if (y[0].StartsWith("["))
                         parameter = parameter.Add(y[0].Replace("[", "").Replace("]", ""), y[1]).IsOptional();
                     else
                         parameter = parameter.Add(y[0], y[1]);
                 });
         return parameters;
     }
     catch
     {
         return new BaseCommandHandlerParameter(
             "Usage string is not in the right format: " +
             "Description string=>Parameter1|Parameter1 description||" +
             "Parameter2|Parameter2 description",
             definition);
     }
 }
        public BaseCommandHandlerParameter Insert(string name, string description)
        {
            var parameter = new BaseCommandHandlerParameter(name, description);

            _parameters.Insert(0, parameter);
            return(parameter);
        }
示例#3
0
        private string listUsages(BaseCommandHandlerParameter command)
        {
            var usage = command.Name + "|\"" + command.Description + "\"";

            command.Parameters.ToList()
            .ForEach(x => usage += " " + listUsages(x));
            return(usage + " end ");
        }
示例#4
0
        private BaseCommandHandlerParameter getUsage(string template)
        {
            var name       = Path.GetFileNameWithoutExtension(template);
            var definition = new NewTemplate(template, null, _keyPath).GetUsageDefinition();
            var parser     = new TemplateDefinitionParser();
            var usage      = parser.Parse(name, definition);

            if (usage == null)
            {
                return(null);
            }
            var fileParam = new BaseCommandHandlerParameter("FILE", "Path to the file to be create");

            usage.Parameters.ToList()
            .ForEach(x => fileParam.Add(x));
            usage = new BaseCommandHandlerParameter(usage.Name, usage.Description);
            usage.Add(fileParam);
            return(usage);
        }
示例#5
0
 public BaseCommandHandlerParameter Parse(string name, string definition)
 {
     try
     {
         if (!definition.Contains("=>"))
         {
             return(new BaseCommandHandlerParameter(name, definition));
         }
         var chunks     = definition.Split(new string[] { "=>" }, StringSplitOptions.None);
         var parameters = new BaseCommandHandlerParameter(name, chunks[0]);
         BaseCommandHandlerParameter parameter = parameters;
         chunks[1]
         .Split(new string[] { "||" }, StringSplitOptions.None).ToList()
         .ForEach(x =>
         {
             var y = x.Split(new string[] { "|" }, StringSplitOptions.None);
             if (y[0].StartsWith("["))
             {
                 parameter = parameter.Add(y[0].Replace("[", "").Replace("]", ""), y[1]).IsOptional();
             }
             else
             {
                 parameter = parameter.Add(y[0], y[1]);
             }
         });
         return(parameters);
     }
     catch
     {
         return(new BaseCommandHandlerParameter(
                    "Usage string is not in the right format: " +
                    "Description string=>Parameter1|Parameter1 description||" +
                    "Parameter2|Parameter2 description",
                    definition));
     }
 }
示例#6
0
 private string listUsages(BaseCommandHandlerParameter command)
 {
     var usage = command.Name + "|\"" + command.Description + "\"";
     command.Parameters.ToList()
         .ForEach(x => usage += " " + listUsages(x));
     return usage + " end ";
 }
示例#7
0
 private BaseCommandHandlerParameter getUsage(string template)
 {
     var name = Path.GetFileNameWithoutExtension(template);
     var definition = new CreateTemplate(template, null, _keyPath).GetUsageDefinition();
     var parser = new TemplateDefinitionParser();
     var usage = parser.Parse(name, definition);
     if (usage == null)
         return null;
     var fileParam = new BaseCommandHandlerParameter("ITEM_NAME", "The name of the Project/Item to create");
     usage.Parameters.ToList()
         .ForEach(x => fileParam.Add(x));
     usage = new BaseCommandHandlerParameter(usage.Name, usage.Description);
     usage.Add(fileParam);
     return usage;
 }
 public BaseCommandHandlerParameter Insert(string name, string description)
 {
     var parameter = new BaseCommandHandlerParameter(name, description);
     _parameters.Insert(0, parameter);
     return parameter;
 }
 public BaseCommandHandlerParameter Add(BaseCommandHandlerParameter parameter)
 {
     _parameters.Add(parameter);
     return parameter;
 }
 public BaseCommandHandlerParameter Add(string name, string description)
 {
     var parameter = new BaseCommandHandlerParameter(name, description);
     _parameters.Add(parameter);
     return parameter;
 }
 public BaseCommandHandlerParameter Add(BaseCommandHandlerParameter parameter)
 {
     _parameters.Add(parameter);
     return(parameter);
 }
示例#12
0
 private BaseCommandHandlerParameter getUsage(string template)
 {
     var name = Path.GetFileNameWithoutExtension(template);
     var definition = new NewTemplate(template, null).GetUsageDefinition();
     var parser = new TemplateDefinitionParser();
     var usage = parser.Parse(name, definition);
     if (usage == null)
         return null;
     var fileParam = new BaseCommandHandlerParameter("FILE", "Path to the file to be create");
     usage.Parameters.ToList()
         .ForEach(x => fileParam.Add(x));
     usage = new BaseCommandHandlerParameter(usage.Name, usage.Description);
     usage.Add(fileParam);
     return usage;
 }