forked from pool/python-click-man
* Fix typo * Explicitly require setuptools, __main__.py imports pkg_resources * Fix typos * Update README.md * Fix typo * tests: Switch to pytest * Add GitHub Actions workflow, remove Travis * Fix man generation for CLI with hidden options * Move 'cli()' method to 'click_man.shell' * Add shell unit tests * cli: Expose knobs for date and version * README: Remove references to distutils command * Remove distutils command * Remove use of pkg_resources * Drop support for Python < 3.9 * Add ruff configuration * Format with ruff-format * Add pre-commit * Add lint CI job * Migrate to pyproject.toml - from version 0.4.2 * get_short_help method only exists in Click 7. - Add update-alternatives to Requires(post) and Requires(postun) - Drop get-short-help.patch, merged upstream - Limit Python files matched in %files section - Switch package to modern Python Stack on SLE-15 * Use Python 3.11 on SLE-15 by default * Drop support for older Python versions - Switch build system from setuptools to pyproject.toml OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-click-man?expand=0&rev=9
37 lines
1.4 KiB
Diff
37 lines
1.4 KiB
Diff
Index: click-man-0.4.1/click_man/core.py
|
|
===================================================================
|
|
--- click-man-0.4.1.orig/click_man/core.py
|
|
+++ click-man-0.4.1/click_man/core.py
|
|
@@ -16,6 +16,14 @@ import click
|
|
|
|
from .man import ManPage
|
|
|
|
+
|
|
+def get_short_help_str(command, limit=45):
|
|
+ """
|
|
+ Gets short help for the command or makes it by shortening the long help string.
|
|
+ """
|
|
+ return command.short_help or command.help and click.utils.make_default_short_help(command.help, limit) or ''
|
|
+
|
|
+
|
|
def generate_man_page(ctx, version=None):
|
|
"""
|
|
Generate documentation for the given command.
|
|
@@ -29,14 +37,14 @@ def generate_man_page(ctx, version=None)
|
|
# Create man page with the details from the given context
|
|
man_page = ManPage(ctx.command_path)
|
|
man_page.version = version
|
|
- man_page.short_help = ctx.command.get_short_help_str()
|
|
+ man_page.short_help = get_short_help_str(ctx.command)
|
|
man_page.description = ctx.command.help
|
|
man_page.synopsis = ' '.join(ctx.command.collect_usage_pieces(ctx))
|
|
man_page.options = [x.get_help_record(ctx) for x in ctx.command.params if isinstance(x, click.Option)]
|
|
commands = getattr(ctx.command, 'commands', None)
|
|
if commands:
|
|
man_page.commands = [
|
|
- (k, v.get_short_help_str()) for k, v in commands.items()
|
|
+ (k, get_short_help_str(v)) for k, v in commands.items()
|
|
]
|
|
|
|
return str(man_page)
|