跳转到主要内容

一个为poetry提供的插件,允许您使用pyinvoke执行tasks.py中定义的脚本。受poetry-exec-plugin启发。

项目描述

poetry-pyinvoke-plugin

一个为poetry提供的插件,允许您调用tasks.py文件中的命令,并将任务委托给pyinvoke

深受poetry-exec-plugin项目上keattang的工作的启发。

安装

安装需要poetry 1.6.0+。要安装此插件,请运行

pip install poetry-pyinvoke-plugin
# OR
poetry self add poetry-pyinvoke-plugin

有关安装插件的其它方法的详细信息,请参阅poetry文档

快速入门

有关如何设置tasks.py文件的详细信息,请参阅配置

列出所有任务

poetry inv -- --list

运行任务

poetry invoke lint
# OR
poetry inv lint

用户指南

配置

tasks.py

from invoke import task

@task
def lint(c):
  c.run("flake8")
  c.run("black --check .")

命令行使用

快速入门

然后

poetry inv -- --list

示例输出

Invoke: invoke --list 

Available tasks:

  build      Build wheel.
  format     Autoformat code for code style.
  greeting   Example task that takes an argument for testing purposes.
  lint       Linting and style checking.
  test       Run test suite.

运行任务

poetry invoke lint
# OR
poetry inv lint

您可以使用poetry invokepoetry inv。本文档的其余部分将使用poetry inv

详细命令使用

列出所有任务

此操作使用--将参数断开连接,并将剩余参数传递给invoke

命令

poetry inv -- --list

示例输出

Invoke: invoke --list 

Available tasks:

  build      Build wheel.
  format     Autoformat code for code style.
  greeting   Example task that takes an argument for testing purposes.
  lint       Linting and style checking.
  test       Run test suite.

运行任务

命令

poetry inv lint

示例输出

Invoke: invoke lint 

All done!  🍰 3 files would be left unchanged.
Skipped 3 files
Success: no issues found in 2 source files

带有参数的任务

单个位置参数

命令

poetry inv greeting Loki

示例输出

Invoke: invoke greeting Loki

Hello Loki, from Sylvie

命令

poetry inv greeting -- Loki

示例输出

Invoke: invoke greeting Loki

Hello Loki, from Sylvie

命名参数

命令

poetry inv greeting -- --name Loki

示例输出

Invoke: invoke greeting --name Loki

Hello Loki, from Sylvie

命令

poetry inv greeting -- -n Loki

示例输出

Invoke: invoke greeting -n Loki

Hello Loki, from Sylvie

多个命名参数

命令

poetry inv greeting -- --name Loki --other Thor

示例输出

Invoke: invoke greeting --name Loki --other Thor

Hello Loki, from Thor

命令

poetry inv greeting -- -n Loki -o Thor

示例输出

Invoke: invoke greeting -n Loki -o Thor

Hello Loki, from Thor

任务帮助

此操作使用--将参数断开连接,并将剩余参数传递给invoke。它还在task命令之前使用--help来获取其帮助信息。

命令

poetry inv -- --help greeting

示例输出

Invoke: invoke --help greeting

Usage: inv[oke] [--core-opts] greeting [--options] [other tasks here ...]

Docstring:
  Example task that takes an argument for testing purposes.

Options:
  -n STRING, --name=STRING
  -o STRING, --other=STRING

插件帮助

命令

poetry inv --help

示例输出

Description:
  Delegate out to pyinvoke tasks specified in your tasks.py file

Usage:
  inv [options] [--] <cmd> [<arguments>...]

Arguments:
  cmd                        The command to run from your tasks.py.
  arguments                  Additional arguments to append to the command.

Invoke帮助

此操作使用--将参数断开连接,并将剩余参数传递给invoke

命令

poetry inv -- --help

示例输出

Invoke: invoke --help 

Usage: inv[oke] [--core-opts] task1 [--task1-opts] ... taskN [--taskN-opts]

发布

要发布新版本,请从main创建一个发布版本(在拉取请求之后)。

贡献

在任何时候,您都有权力分叉此项目,根据您的需要进行更改,然后

pip install https://github.com/user/repository/archive/branch.zip

Stackoverflow:从GitHub分支安装pip

这样您可以在中间或甚至在内部运行您自己的自定义分叉,只需将此项目作为起点即可。这是完全可以接受的。

但是,如果您想将您的更改贡献回来,那么请打开“跨分叉”的拉取请求。

一旦您的更改合并并发布,您就可以恢复到pip安装此包的规范版本。

如果您不确定如何进行更改或是否应该投入时间和精力,那么请打开一个Issue,我们可以讨论并分类问题。

由以下机构支持

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