We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用 pdm init 初始化项目 在包内 __init__ 中添加内容
pdm init
__init__
from pdm.core import Core from .command import HelloCommand def hello_plugin(core: Core): core.register_command(HelloCommand, "hello")
同目录新建了一个文件 command.py
command.py
from pdm.cli.commands.base import BaseCommand class HelloCommand(BaseCommand): """向指定的人打招呼。 如果未指定,将从"hello.name"配置中读取。 """ name = 'hello' def add_arguments(self, parser): parser.add_argument("-n", "--name", help="要问候的人的姓名") def handle(self, project, options): if not options.name: name = project.config["hello.name"] else: name = options.name print(f"Hello, {name}")
在 pyproject.toml 文件中添加
pyproject.toml
[tool.pdm] distribution = false plugins = [ "-e file:///${PROJECT_ROOT}" ]
在命令行执行
pdm install --plugins
执行 pdm self list 也能看到注册的插件,但是使用 pdm hello 这个命令会出现错误
pdm self list
pdm hello
$ pdm hello 123 Usage: pdm [-h] [-V] [-c CONFIG] [-v | -q] [--no-cache] [-I] [--pep582 [SHELL]] [-n] ... pdm: error: Script unknown: hello
The text was updated successfully, but these errors were encountered:
No branches or pull requests
使用
pdm init
初始化项目在包内
__init__
中添加内容同目录新建了一个文件
command.py
在
pyproject.toml
文件中添加在命令行执行
执行
pdm self list
也能看到注册的插件,但是使用pdm hello
这个命令会出现错误$ pdm hello 123 Usage: pdm [-h] [-V] [-c CONFIG] [-v | -q] [--no-cache] [-I] [--pep582 [SHELL]] [-n] ... pdm: error: Script unknown: hello
The text was updated successfully, but these errors were encountered: