Exemplo n.º 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());
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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");
 }
Exemplo n.º 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();
 }
Exemplo n.º 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)
 {
 }
Exemplo n.º 7
0
 protected virtual void WriteNoHelpTextAvailable(PropertyHelpRequest property)
 {
 }