/// <summary>Gets the help information for the class of the given type.</summary> /// <param name="argumentType">The argument class for creating the help for</param> /// <returns>An <see cref="IEnumerable{T}"/> of <see cref="ArgumentHelp"/></returns> public IEnumerable <ArgumentHelp> GetHelpForProperties([NotNull] Type argumentType) { if (argumentType == null) { throw new ArgumentNullException(nameof(argumentType)); } PropertyInfo[] properties = argumentType.GetProperties(BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo info in properties) { var commandLineAttribute = info.GetAttribute <CommandLineAttribute>(); var helpText = info.GetAttribute <HelpTextAttribute>(); if (helpText != null) { yield return(new ArgumentHelp { PropertyName = GetArgumentName(info, commandLineAttribute), Aliases = GetAliases(commandLineAttribute), UnlocalizedDescription = helpText.Description, LocalizedDescription = CommandLineEngine.GetLocalizedDescription(resourceManager, helpText.ResourceKey), Priority = helpText.Priority, Required = IsRequired(commandLineAttribute) }); } } }
protected virtual void WriteHelpText(string resourceKey, string description) { if (resourceManager != null && !string.IsNullOrEmpty(resourceKey)) { var helpTextString = CommandLineEngine.GetLocalizedDescription(resourceManager, resourceKey); Console.WriteLine($"- {helpTextString}"); } else { if (description != null) { Console.WriteLine($"- {description}"); } } }