cyclopts-cli-scripts
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCLI Scripts with cyclopts
基于cyclopts的CLI脚本
All command-line scripts in this codebase use the framework.
cyclopts本代码库中的所有命令行脚本均使用****框架。
cycloptsFramework
框架选择
Use , not , , , or bare .
cycloptsargparseclicktypersys.argvpython
import cyclopts
app = cyclopts.App()
@app.command
def my_command(arg1: str, flag: bool = False) -> None:
"""Brief description shown in --help."""
...
if __name__ == "__main__":
app()使用,而非、、或原生。
cycloptsargparseclicktypersys.argvpython
import cyclopts
app = cyclopts.App()
@app.command
def my_command(arg1: str, flag: bool = False) -> None:
"""Brief description shown in --help."""
...
if __name__ == "__main__":
app()Location
文件位置
Place scripts in the directory at the root of the relevant project or
repository. Do not place scripts in , , or ad-hoc locations.
bin/src/scripts/将脚本放置在相关项目或仓库根目录的目录下。请勿将脚本放在、或临时位置。
bin/src/scripts/Naming
命名规范
Use hyphen-separated names: , .
bin/migrate-assetsbin/sync-catalog使用连字符分隔的命名方式:、。
bin/migrate-assetsbin/sync-catalogRegistering with uv
通过uv注册脚本
If the script should be runnable via , register it in
:
uv run <script-name>pyproject.tomltoml
[project.scripts]
my-script = "my_package.bin.my_script:app"Or place the script directly in and run it with:
bin/bash
uv run python bin/my-script如果脚本需要通过运行,请在中进行注册:
uv run <script-name>pyproject.tomltoml
[project.scripts]
my-script = "my_package.bin.my_script:app"或者直接将脚本放在目录下,通过以下命令运行:
bin/bash
uv run python bin/my-script