跳转到主要内容

将 --help 和 --version 转换为 man 页。

项目描述

help2man

pre-commit.ci status github/workflow codecov readthedocs

github/downloads github/downloads/latest github/issues github/issues-closed github/issues-pr github/issues-pr-closed github/discussions github/milestones github/forks github/stars github/watchers github/contributors github/commit-activity github/last-commit github/release-date

github/license github/languages github/languages/top github/directory-file-count github/code-size github/repo-size github/v

pypi/status pypi/v pypi/downloads pypi/format pypi/implementation pypi/pyversions

--help--version 转换为 man 页。

类似项目

  • GNU help2man 为具有 --help--version 的任何程序生成 man 页。用 perl 编写。
  • click-man 为基于 click 的 Python 程序生成 man 页。用 python 编写。
  • cli2man 为具有 --help--version 的任何程序生成 man 页和 markdown。用 python 编写。
  • 本项目:为具有 --help--version 或基于 argparse 的任何 Python 程序生成 man 页、markdown 或任何格式(如果您提供了一个 jinja 模板)。

意图

这是 GNU help2man 的 Python 版本。它解决了以下问题[^email]

GNU help2man 无法正确转换 argparse

因为 argparse 输出

usage: help2man [-h] ...
                executable ...

Convert --help and --version to man page.

positional arguments:
  executable            executable program name
  ...

options:
  -h                    show this help message and exit
  ...

help2man 将忽略 位置参数:选项:,因为它只检测到 选项:。它错误地将第一行视为摘要,并将其他行视为描述。

GNU help2man 无法自定义模板

我提供了 help2man --template XXXhelp2man --template-file XXX 来实现这一点。模板语言是 jinja2。请参阅 模板 作为示例。

GNU help2man 不提供任何编程 API

现在您可以在 Python 中使用它。如果您想在构建 Python 项目时自动生成 man 页面,请参阅 setuptools-generate

参阅 文档 了解更多信息。

[^email]: 我向 GNU help2man 的作者发送了电子邮件,但没有收到回复。

项目详情


下载文件

下载适合您平台文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源代码分发

help2man-0.0.9.tar.gz (36.0 kB 查看散列)

上传时间 源代码

构建分发

help2man-0.0.9-py3-none-any.whl (28.7 kB 查看散列)

上传时间 Python 3

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页