private string GetArgumentName(PropertyHelpRequest request) { string primaryName = request.Property.Name; var attribute = request.CommandLineAttribute; if (attribute?.Name != null) { return(attribute.Name.ToLowerInvariant()); } return(primaryName.ToLowerInvariant()); }
/// <summary>Prints the help for the given property.</summary> /// <param name="property">The argument property.</param> public void PrintPropertyHelp([NotNull] PropertyInfo property) { if (property == null) { throw new ArgumentNullException(nameof(property)); } var helpRequest = new PropertyHelpRequest(property); WritePropertyHeader(helpRequest); WritePropertyContent(helpRequest); WritePropertyFooter(helpRequest); }
private void WritePropertyContent(PropertyHelpRequest property) { if (property.DetailedHelpTextAttribute != null) { WriteHelpText(property.DetailedHelpTextAttribute.ResourceKey, property.DetailedHelpTextAttribute.Description); } else if (property.HelpTextAttribute != null) { WriteHelpText(property.HelpTextAttribute.ResourceKey, property.HelpTextAttribute.Description); } else { WriteNoHelpTextAvailable(property); } }
private string GetCommandLineTyp(PropertyHelpRequest helpRequest) { if (helpRequest.CommandLineAttribute is OptionAttribute) { return("option"); } if (helpRequest.CommandLineAttribute is ArgumentAttribute) { return("argument"); } if (helpRequest.CommandLineAttribute is CommandAttribute) { return("command"); } return("property"); }
/// <summary>Writes the header for a property help request.</summary> /// <param name="helpRequest">The property.</param> protected virtual void WritePropertyHeader(PropertyHelpRequest helpRequest) { Console.WriteLine($"Help for the {GetCommandLineTyp(helpRequest)} '{GetArgumentName(helpRequest)}'"); Console.WriteLine(); }
/// <summary>Writes the footer for a property help request.</summary> /// <param name="property">The property the help was requested for.</param> protected virtual void WritePropertyFooter(PropertyHelpRequest property) { }
protected virtual void WriteNoHelpTextAvailable(PropertyHelpRequest property) { }