在命令行中运行带别名的 python 命令,如 npm

2024-01-23

在node中,您可以定义一个package.json。然后定义一个script块如下:

"scripts": {
    "start": "concurrently -k -r -s first \"yarn test:watch\" \"yarn open:src\" \"yarn lint:watch\"",
  },

所以在根目录中,我可以这样做yarn start to run concurrently -k -r -s first \"yarn test:watch\" \"yarn open:src\" \"yarn lint:watch\"

Python 3 中的等效项是什么?如果我想要一个名为python test to run python -m unittest discover -v


use make https://en.wikipedia.org/wiki/Make_(software), 这很棒。

创建一个Makefile并添加一些目标来运行特定的 shell 命令:


install:
    pip install -r requirements.txt

test:
    python -m unittest discover -v


# and so on, you got the idea

运行(假设Makefile在当前目录中):

make test

注意:如果您想在目标内的同一环境中运行更多命令,请执行以下操作:

install:
    source ./venv/bin/activate; \
    pip install -r requirements.txt; \
    echo "do other stuff after in the same environment"

关键是;\它将命令放在一次运行中,并且 make 将这些命令作为一行执行,因为;\。中的空间; \只是为了美观。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在命令行中运行带别名的 python 命令,如 npm 的相关文章

随机推荐