recline.commands.man_utils module
Original © NetApp 2024
This module holds some utility functions used as part of the man command to format text from CLI commands into consistent man pages that respond to the terminal width.
- recline.commands.man_utils.generate_help_text(screen_width, command_class)
Generates lines of help text which are formatted using the curses library. The final document resembles a typical Linux-style manpage. See here: https://www.tldp.org/HOWTO/Man-Page/q3.html
- recline.commands.man_utils.wrapped_string(text, screen_width, prefix=0)
This function will take a string and make sure it can fit within the given screen_width.
If the string is too long to fit, it will be broken on word boundaries (specifically the ‘ ‘ character) if it can or the word will be split with a ‘-’ character and the second half moved to the next line.
If a prefix is given, the line(s) will be prefixed with that many ‘ ‘ characters, including any wrapped lines.
If the given string includes embedded newline characters, then each line will be evaluated according to the rules above including breaking on word boundaries and injecting a prefix.