Appearance¶
The appearance package contains the layout, color, and help-formatting objects used to control how Interfacy renders CLI help.
Base Types¶
The base appearance classes are configuration-heavy. For these objects, the
constructor signature is the useful part of the API; the inherited rendering
methods are documented once on HelpLayout instead of repeated on every preset.
HelpLayout¶
Base layout configuration object used by the appearance system. Its constructor parameters define the available formatting knobs.
Grouped command listings can be tuned with command_indent for the global
command-row indentation and command_group_spacing for the number of blank
lines inserted between help-group sections.
- HelpLayout.format_argument(arg, indent=2)[source]¶
Format one argument schema as a rendered help line.
- HelpLayout.format_description(description)[source]¶
Format a description string for help output.
- Parameters:
description (str) – Raw description text.
- HelpLayout.format_parameter(param, flags)[source]¶
Format a parameter using the active layout template.
- HelpLayout.format_usage_metavar(name, *, is_varargs=False)[source]¶
Format a metavar token for usage output.
- HelpLayout.get_command_description(
- command,
- ljust,
- name=None,
- aliases=(),
Format a command description line for listings.
- HelpLayout.get_commands_ljust(max_display_len)[source]¶
Compute the left-justify width for command listings.
- Parameters:
max_display_len (int) – Maximum display name length.
- HelpLayout.get_help_for_class(command, *, rules=None)[source]¶
Build help text for class subcommands.
- Parameters:
command (Class) – Inspected class command.
rules (list[HelpSubcommandSortRule] | None) – Optional explicit ordering rules.
- HelpLayout.get_help_for_multiple_commands(commands, *, rules=None)[source]¶
Build a command listing for multiple top-level commands.
- HelpLayout.get_primary_boolean_flag_for_argument(arg)[source]¶
Return the canonical flag token used to display a boolean option.
- Parameters:
arg (Argument) – Argument schema describing a boolean flag.
- HelpLayout.get_subcommand_usage_token()[source]¶
Return the subcommand placeholder token used in usage lines.
- HelpLayout.is_argument_boolean(arg)[source]¶
Return whether an argument schema represents a boolean flag.
- Parameters:
arg (Argument) – Argument schema to inspect.
- HelpLayout.keep_help_default_slot_for_arguments(_arguments)[source]¶
Decide whether to preserve the empty default column for help rows.
- HelpLayout.order_class_methods_for_help(methods, *, rules=None)[source]¶
Return class methods sorted by the active help-subcommand ordering rules.
- HelpLayout.order_commands_for_help(commands, *, rules=None)[source]¶
Return commands sorted by the active help-subcommand ordering rules.
- HelpLayout.order_option_arguments_for_help(options, *, rules=None)[source]¶
Return options sorted by the active help-option ordering rules.
- HelpLayout.prepare_default_field_width_for_arguments(arguments)[source]¶
Compute default-column widths for a batch of rendered arguments.
- HelpLayout.prepare_default_field_width_for_params(params)[source]¶
Compute default column width from parameter defaults.
- Parameters:
params (list[Parameter]) – Parameters to inspect.
Object |
Purpose |
|---|---|
|
Base color-theme container for help rendering styles. |
|
Interfacy-branded layout preset built on |
Layouts¶
These classes are layout presets built on top of HelpLayout.
Object |
Purpose |
|---|---|
|
Default layout that follows standard |
|
Alias of |
|
Layout tuned to closely mirror |
|
Compact aligned layout with a dedicated default-value column. |
|
|
|
More spacious modern layout with stronger visual separation. |
|
Layout inspired by Rust |
Color Themes¶
Color presets expose configuration through their constructor fields and do not add a separate callable API.
Object |
Purpose |
|---|---|
|
Monochrome theme with no accent colors. |
|
Theme inspired by aurora palettes. |
|
Theme that mimics |
Help Sorting¶
- HelpOptionSortRule¶
alias of
Literal[‘required_first’, ‘short_first’, ‘value_first’, ‘bool_last’, ‘no_default_first’, ‘choices_first’, ‘name_length’, ‘alias_count’, ‘alphabetical’]
- HELP_OPTION_SORT_RULE_VALUES: tuple[HelpOptionSortRule, ...] = ('required_first', 'short_first', 'value_first', 'bool_last', 'no_default_first', 'choices_first', 'name_length', 'alias_count', 'alphabetical')¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- DEFAULT_HELP_OPTION_SORT_RULES: tuple[HelpOptionSortRule, ...] = ('required_first', 'short_first', 'bool_last', 'alphabetical')¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- normalize_sort_rule_name(value)[source]¶
Normalize a sort-rule token for case/format-insensitive matching.
- resolve_sort_rules(
- value,
- *,
- value_name,
- allowed_values,
- allow_none=True,
- empty_means_none=True,
Validate and normalize a list of named sort rules.
- resolve_help_option_sort_rules(
- value,
- *,
- value_name='help_option_sort',
- allow_none=True,
- empty_means_none=True,
Validate and normalize help option sort rules.
- default_help_option_sort_rules()[source]¶
Return a mutable copy of the global default help option sort rules.
- HelpSubcommandSortRule¶
alias of
Literal[‘insert_order’, ‘alphabetical’, ‘name_length_asc’, ‘name_length_desc’]
- HELP_SUBCOMMAND_SORT_RULE_VALUES: tuple[HelpSubcommandSortRule, ...] = ('insert_order', 'alphabetical', 'name_length_asc', 'name_length_desc')¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- DEFAULT_HELP_SUBCOMMAND_SORT_RULES: tuple[HelpSubcommandSortRule, ...] = ('insert_order',)¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
Type Formatting¶
TypeStyleTheme is the protocol consumed by TypeHelpFormatter when styling
type tokens.
Rendering¶
SchemaHelpRenderer¶
Turns schema objects into final help text using a selected layout.
- SchemaHelpRenderer.render_parser_help(schema, prog)[source]¶
Render help text for a parser schema and program name.
- Parameters:
schema (ParserSchema) – Parser schema to render.
prog (str) – Program name or invocation prefix.
- SchemaHelpRenderer.render_command_help(
- command,
- prog,
- *,
- parser_description=None,
- parser_epilog=None,
- parser_executable_flags=None,
Render help text for one command schema.
- Parameters:
command (Command) – Command schema to render.
prog (str) – Program name or invocation prefix.
parser_description (str | None) – Optional parser-level description override.
parser_epilog (str | None) – Optional parser-level epilog text.
parser_executable_flags (list[ExecutableFlag] | None) – Parser-level executable flags to merge into single-command help output.