예제 #1
0
        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());
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
 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);
     }
 }
예제 #4
0
 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");
 }
예제 #5
0
 /// <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();
 }
예제 #6
0
 /// <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)
 {
 }
예제 #7
0
 protected virtual void WriteNoHelpTextAvailable(PropertyHelpRequest property)
 {
 }