Skip to content

Consider an alternative that doesn't have HelpBuilder.Default as a nested class #1931

Open
@jonsequitur

Description

@jonsequitur
        // Nested classes are prohibited if (handwaving) more than 30 people in the world will ever need to use them. (Or a few very niche situations that don't apply here).
        // Probably wants to be something like "HelpDefaults" as a top level type.
        public static class Default
        {
            // All of these feel like properties.
            public static HelpSectionDelegate AdditionalArgumentsSection();
            public static HelpSectionDelegate CommandArgumentsSection();
            public static HelpSectionDelegate CommandUsageSection();
            public static HelpSectionDelegate OptionsSection();
            public static HelpSectionDelegate SubcommandsSection();
            public static HelpSectionDelegate SynopsisSection();
 
            // I don't understand what these mean in the context of HelpDefaults.  Like, the first one feels like it's just `argument.GetDefaultValue()?.ToString()`.
            // If it's not, it needs a better name.
            public static string GetArgumentDefaultValue(Argument argument);
            public static string GetArgumentDescription(Argument argument);
            public static string GetArgumentUsageLabel(Argument argument);
            public static string GetIdentifierSymbolDescription(IdentifierSymbol symbol);
            public static string GetIdentifierSymbolUsageLabel(IdentifierSymbol symbol, HelpContext context);
 
            // GetDefaultLayout, maybe?
            public static IEnumerable<HelpSectionDelegate> GetLayout();
        }
    }
 
    // To instance methods.
    public static class HelpBuilderExtensions 
    {
        public static void CustomizeSymbol(this HelpBuilder builder, Symbol symbol, string firstColumnText = null, string secondColumnText = null, string defaultValue = null);
        public static void Write(this HelpBuilder helpBuilder, Command command, TextWriter writer);
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions