Ejemplo n.º 1
0
 private void PrintJsonHelpOutput(string commandName)
 {
     commandOutputProvider.Json(new
     {
         Command = commandName,
         Options = Options.OptionSets.OrderByDescending(x => x.Key).Select(g => new
         {
             @Group     = g.Key,
             Parameters = g.Value.Select(p => new
             {
                 Name  = p.Names.First(),
                 Usage = string.Format("{0}{1}{2}", p.Prototype.Length == 1 ? "-" : "--", p.Prototype,
                                       p.Prototype.EndsWith("=") ? "VALUE" : string.Empty),
                 Value = p.OptionValueType.ToString(),
                 p.Description
             })
         })
     });
 }
Ejemplo n.º 2
0
 private void PrintJsonHelpOutput(TextWriter writer, string commandName, string description)
 {
     commandOutputProvider.Json(new
     {
         Command     = commandName,
         Description = description,
         Options     = Options.OptionSets.OrderByDescending(x => x.Key).Select(g => new
         {
             @Group     = g.Key,
             Parameters = g.Value.Select(p => new
             {
                 Name  = p.Names.First(),
                 Usage = string.Format("{0}{1}{2}", p.Prototype.Length == 1 ? "-" : "--", p.Prototype,
                                       p.Prototype.EndsWith("=") ? "VALUE" : string.Empty),
                 p.Description,
                 Type      = p.Type.Name,
                 Sensitive = p.Sensitive ? (bool?)true : null,
                 Values    = (p.Type.IsEnum) ? Enum.GetNames(p.Type) : null
             })
         })
     }, writer);
 }
Ejemplo n.º 3
0
 private void PrintJsonHelpOutput(TextWriter writer, string commandName, string description)
 {
     commandOutputProvider.Json(new
     {
         Command     = commandName,
         Description = description,
         Options     = Options.OptionSets.OrderByDescending(x => x.Key).Select(g => new
         {
             @Group     = g.Key,
             Parameters = g.Value.Select(p => new
             {
                 Name  = p.Names.First(),
                 Usage = $"{(p.Prototype.Length == 1 ? "-" : "--")}{p.Prototype}{(p.Prototype.EndsWith("=") ? "VALUE" : string.Empty)}",
                 p.Description,
                 Type           = p.Type.Name,
                 Sensitive      = p.Sensitive ? (bool?)true : null,
                 AllowsMultiple = p.AllowsMultiple ? (bool?)true : null, //allows tools (such as nuke.build) to auto-generate better code
                 Values         = p.Type.IsEnum ? Enum.GetNames(p.Type).Where(x => p.Type.GetField(x).GetCustomAttribute <ObsoleteAttribute>() == null) : null
             })
         })
     }, writer);
 }