如何为 python Invoke 编写面向对象的任务?

How to write object oriented tasks for python Invoke?

Fabric 1 提供了一种编写基于 class 的任务的方法。这是一个例子

from fabric.tasks import Task
from fabric.api import local

class FooTask(Task):
    def run(self):
        local("ls")

我开始过渡到使用 Fabric 2,并希望将我的任务移植到使用 classes 的 Invoke。可以吗?

据我所知 Invoke 不支持这个。我的解决方案是使用 Fabric 3,它是原始 Fabric 的直接替代品。