dryparse.help
Help module for dryparse objects.
- class Help
Hierarchical representation of a help message. You can customize every individual part or subpart of it, or its entirety.
- text: str
The entire help text.
Overriding this property makes all the other properties obsolete.
- class CommandHelp(command: Command)
Object that represents a command’s help message organized as a hierarchy.
- signature: str
Describes the command signature when listed as a subcommand in the help message of another command.
Defaults to the command name.
- desc: dryparse.help.CommandDescription
Command description.
You can assign this to be a
str
orCommandDescription
, but you will always get aCommandDescription
when you try to access this as an attribute.
- sections: dryparse.help.HelpSectionList
Sections of this help message.
Default implementation returns a standard command section list including “usage”, “subcommands”, etc.
- section_separator: str
Separator between sections of this help message.
- listing: dryparse.help.HelpEntry
Text that appears when this subcommand is listed as a subcommand in the help message of another command.
- text: str
- class OptionHelp(option: Option)
Attributes
- override_class: Optional[Type[OptionHelp]]
When instantiating an object of type
OptionHelp
, return an instance ofoverride_class
instead.
- desc: str
Option description.
- argname: str
Name of the argument to this option.
- signature: str
Option signature.
Default value:
-o ARGNAME, --option ARGNAME
, if the option takes an argument-o ARGNAME
, if the option only has a short text--option ARGNAME
, if the option only has a long text--o ARGNAME
, if the option only has a short textARGNAME
is omitted if the option takes no argument
- hint: str
Hint for the option that appears in the “usage” section of a command.
Default value:
[-o ARGNAME]
, if the option has a short text[--option ARGNAME]
, if the option has no short textARGNAME
is omitted if the option does not take an argument
- text: str
- class HelpSection(name_or_group: Union[str, Group])
Help section, with a headline and content.
- name: str
Section name.
- group: Optional[dryparse.objects.Group]
Group
that this section refers to.
- headline: str
Section headline.
Default value:
f"{self.name}:"
.
- content: str
Section content, excluding headline.
- indent: int
Indent for the content of this section.
- active: bool
Controls whether the section is displayed.
Default value:
True
- text: str
Entire help text.
- class HelpSectionList(iterable=(), /)
A glorified list of help sections.
Behaves exactly like a normal list, with the addition that you can also access individual help sections as attributes, not just by indexing. Sections added using regular list functions can only be accessed by index (and iterators, etc.), while sections added by attribute assignment can also be accessed as attributes. In the latter case, the index is determined by the number of sections that existed before the section was added.
Examples
>>> sections = HelpSectionList() >>> # Create unnamed section at index 0 >>> sections.append(HelpSection("Usage")) >>> # Create section named usage - index automatically set to be 1 >>> sections.commands = HelpSection("Commands") >>> print(sections[0].text) Usage: >>> print(sections.usage.text) Commands: >>> print(sections[1]) Commands:
- class HelpEntry(signature, desc)
Represents an option or subcommand entry in a help message.
- signature_width: int
Width of signature after padding.
Default: 32 characters.
- padded_signature: str
Option signature padded until
signature_width
.
- text: str
Entire help text for this entry.
- class CommandDescription(long, brief=None)
Command description that can hold both a long and a brief version.
Attributes
- long: str
Long description. Used in the help text of the command at hand.
- brief: str
Brief description. Describes this command when it appears as a subcommand in another command’s help text. Falls back to
long
.