npx skills add https://github.com/iloveitaly/ai-skills --skill justfile包含 Shell 命令
此技能包含可能执行系统命令的 shell 命令指令(!command``)。安装前请仔细审查。
下面的自述文件摘自:https://github.com/casey/just/blob/master/README.md
它完整地记录了 Justfile 语法和系统。
just 是一种保存和运行项目特定命令的便捷方式。
此自述文件也可作为书籍获取。该书反映最新发布版本,而 GitHub 上的自述文件 则反映最新的 master 分支。
(中文文档在 这里, 快看过来!)
命令,称为配方(recipes),存储在名为 justfile 的文件中,其语法灵感来源于 make:

然后你可以使用 just RECIPE 运行它们:
$ just test-all
cc *.c -o main
./test --all
Yay, all your tests passed!
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
just 拥有大量有用的功能,并且相比 make 有许多改进:
just 是一个命令运行器,而不是构建系统,因此它避免了 make 的许多复杂性和特殊性。不需要 .PHONY 配方!sh,你需要选择不同的 shell。)just 加载 .env 文件,使得填充环境变量变得容易。just 可以从任何子目录调用,而不仅仅是包含 justfile 的目录。如果你需要 just 方面的帮助,请随时提出 issue 或在 Discord 上联系我。功能请求和错误报告总是受欢迎的!
请参阅安装部分了解如何在你的计算机上安装 just。尝试运行 just --version 以确保其正确安装。
有关语法概述,请查看此备忘单。
一旦 just 安装并正常工作,在你的项目根目录下创建一个名为 justfile 的文件,内容如下:
recipe-name:
echo 'This is a recipe!'
# this is a comment
another-recipe:
@echo 'This is another recipe.'
当你调用 just 时,它会在当前目录及向上查找文件 justfile,因此你可以从项目的任何子目录调用它。
对 justfile 的搜索不区分大小写,因此任何大小写,如 Justfile、JUSTFILE 或 JuStFiLe,都可以工作。just 也会查找名为 .justfile 的文件,以防你想隐藏 justfile。
不带参数运行 just 会运行 justfile 中的第一个配方:
$ just
echo 'This is a recipe!'
This is a recipe!
一个或多个参数指定要运行的配方:
$ just another-recipe
This is another recipe.
just 在运行每个命令之前将其打印到标准错误输出,这就是为什么 echo 'This is a recipe!' 被打印出来。对于以 @ 开头的行,此行为被抑制,这就是为什么 echo 'This is another recipe.' 没有被打印。
如果命令失败,配方将停止运行。这里 cargo publish 只有在 cargo test 成功时才会运行:
publish:
cargo test
# tests passed, time to publish!
cargo publish
配方可以依赖于其他配方。这里 test 配方依赖于 build 配方,所以 build 会在 test 之前运行:
build:
cc main.c foo.c bar.c -o main
test: build
./test
sloc:
@echo "`wc -l *.c` lines of code"
$ just test
cc main.c foo.c bar.c -o main
./test
testing… all tests passed!
没有依赖关系的配方将按照它们在命令行上给出的顺序运行:
$ just build sloc
cc main.c foo.c bar.c -o main
1337 lines of code
依赖项总是会先运行,即使它们在依赖它们的配方之后传递:
$ just test build
cc main.c foo.c bar.c -o main
./test
testing… all tests passed!
配方可能依赖于子模块中的配方:
mod foo
baz: foo::bar
可以在 examples 目录 和 GitHub 上找到各种 justfile。
当 just 在没有配方的情况下被调用时,它会运行带有 [default] 属性的配方,如果没有配方具有 [default] 属性,则运行 justfile 中的第一个配方。
这个配方可能是项目中最频繁运行的命令,比如运行测试:
test:
cargo test
你也可以使用依赖关系来默认运行多个配方:
default: lint build test
build:
echo Building…
test:
echo Testing…
lint:
echo Linting…
如果没有配方适合作为默认配方,你可以在 justfile 的开头添加一个列出可用配方的配方:
default:
just --list
可以使用 just --list 按字母顺序列出配方:
$ just --list
Available recipes:
build
test
deploy
lint
可以使用 just --list PATH 列出子模块中的配方,其中 PATH 是以空格或 :: 分隔的模块路径:
$ cat justfile
mod foo
$ cat foo.just
mod bar
$ cat bar.just
baz:
$ just --list foo bar
Available recipes:
baz
$ just --list foo::bar
Available recipes:
baz
just --summary 更简洁:
$ just --summary
build test deploy lint
传递 --unsorted 以按照配方在 justfile 中出现的顺序打印它们:
test:
echo 'Testing!'
build:
echo 'Building!'
$ just --list --unsorted
Available recipes:
test
build
$ just --summary --unsorted
test build
如果你希望 just 默认列出 justfile 中的配方,你可以使用这个作为默认配方:
default:
@just --list
请注意,你可能需要在上面一行添加 --justfile {{justfile()}}。如果没有它,如果你执行了 just -f /some/distant/justfile -d . 或 just -f ./non-standard-justfile,配方内部的普通 just --list 不一定使用你提供的文件。它会尝试在你的当前路径中查找 justfile,甚至可能导致 No justfile found 错误。
标题文本可以使用 --list-heading 自定义:
$ just --list --list-heading $'Cool stuff…\n'
Cool stuff…
test
build
缩进可以使用 --list-prefix 自定义:
$ just --list --list-prefix ····
Available recipes:
····test
····build
--list-heading 的参数替换标题及其后的换行符,因此如果非空,它应包含换行符。它这样工作是为了让你可以通过传递空字符串来完全抑制标题行:
$ just --list --list-heading ''
test
build
可以在命令行上一次调用多个配方:
build:
make web
serve:
python3 -m http.server -d out 8000
$ just build serve
make web
python3 -m http.server -d out 8000
请记住,带有参数的配方会吞掉参数,即使它们匹配其他配方的名称:
build project:
make {{project}}
serve:
python3 -m http.server -d out 8000
$ just build serve
make: *** No rule to make target `serve'. Stop.
--one 标志可用于将命令行调用限制为单个配方:
$ just --one build serve
error: Expected 1 command-line recipe invocation but found 2.
默认情况下,配方运行时的工作目录设置为包含 justfile 的目录。
[no-cd] 属性可用于使配方运行时的工作目录设置为调用 just 时的目录。
@foo:
pwd
[no-cd]
@bar:
pwd
$ cd subdir
$ just foo
/
$ just bar
/subdir
你可以使用 set working-directory := '…' 覆盖所有配方的工作目录:
set working-directory := 'bar'
@foo:
pwd
$ pwd
/home/bob
$ just foo
/home/bob/bar
你可以使用 working-directory 属性1.38.0 覆盖特定配方的工作目录:
[working-directory: 'bar']
@foo:
pwd
$ pwd
/home/bob
$ just foo
/home/bob/bar
working-directory 设置或 working-directory 属性的参数可以是绝对路径或相对路径。如果是相对路径,则相对于默认工作目录进行解释。
别名允许配方在命令行上以替代名称调用:
alias b := build
build:
echo 'Building!'
$ just b
echo 'Building!'
Building!
别名的目标可以是子模块中的配方:
mod foo
alias baz := foo::bar
设置控制解释和执行。每个设置在 justfile 的任何位置最多只能指定一次。
例如:
set shell := ["zsh", "-cu"]
foo:
# this line will be run as `zsh -cu 'ls **/*.txt'`
ls **/*.txt
| 名称 | 值 | 默认值 | 描述 |
|---|---|---|---|
allow-duplicate-recipes | 布尔值 | false | 允许出现在 justfile 后面的配方覆盖较早的同名配方。 |
allow-duplicate-variables | 布尔值 | false | 允许出现在 justfile 后面的变量覆盖较早的同名变量。 |
dotenv-filename | 字符串 | - | 如果存在,加载具有自定义名称的 .env 文件。 |
dotenv-load | 布尔值 | false | 如果存在,加载 .env 文件。 |
dotenv-override | 布尔值 | false | 使用 .env 文件中的值覆盖现有的环境变量。 |
dotenv-path | 字符串 | - | 从自定义路径加载 .env 文件,如果不存在则报错。覆盖 dotenv-filename。 |
dotenv-required | 布尔值 | false | 如果找不到 .env 文件则报错。 |
export | 布尔值 | false | 将所有变量导出为环境变量。 |
fallback | 布尔值 | false | 如果命令行上的第一个配方未找到,则在父目录中搜索 justfile。 |
ignore-comments | 布尔值 | false | 忽略以 # 开头的配方行。 |
positional-arguments | 布尔值 | false | 传递位置参数。 |
quiet | 布尔值 | false | 在执行前禁用回显配方行。 |
script-interpreter1.33.0 | [COMMAND, ARGS…] | ['sh', '-eu'] | 设置用于调用具有空 [script] 属性的配方的命令。 |
shell | [COMMAND, ARGS…] | - | 设置用于调用配方和评估反引号的命令。 |
tempdir | 字符串 | - | 在 tempdir 中创建临时目录,而不是系统默认的临时目录。 |
unstable1.31.0 | 布尔值 | false | 启用不稳定功能。 |
windows-powershell | 布尔值 | false | 在 Windows 上使用 PowerShell 作为默认 shell。(已弃用。请改用 windows-shell。) |
windows-shell | [COMMAND, ARGS…] | - | 设置用于调用配方和评估反引号的命令。 |
working-directory1.33.0 | 字符串 | - | 设置配方和反引号的工作目录,相对于默认工作目录。 |
布尔设置可以写成:
set NAME
这等同于:
set NAME := true
非布尔设置可以设置为字符串和表达式1.46.0。
但是,由于设置会影响反引号和许多函数的行为,这些表达式不能直接或通过引用间接包含反引号或函数调用。
如果 allow-duplicate-recipes 设置为 true,定义多个同名配方不是错误,并且使用最后一个定义。默认为 false。
set allow-duplicate-recipes
@foo:
echo foo
@foo:
echo bar
$ just foo
bar
如果 allow-duplicate-variables 设置为 true,定义多个同名变量不是错误,并且使用最后一个定义。默认为 false。
set allow-duplicate-variables
a := "foo"
a := "bar"
@foo:
echo {{a}}
$ just foo
bar
如果设置了 dotenv-load、dotenv-filename、dotenv-override、dotenv-path 或 dotenv-required 中的任何一个,just 将尝试从文件加载环境变量。
如果设置了 dotenv-path,just 将在给定路径查找文件,该路径可以是绝对路径,也可以是相对于工作目录的路径。
命令行选项 --dotenv-path,简写 -E,可用于在运行时设置或覆盖 dotenv-path。
如果设置了 dotenv-filename,just 将在相对于工作目录及其每个祖先的给定路径查找文件。
如果未设置 dotenv-filename,但设置了 dotenv-load 或 dotenv-required,just 将查找名为 .env 的文件,相对于工作目录及其每个祖先。
dotenv-filename 和 dotenv-path 类似,但 dotenv-path 仅相对于工作目录检查,而 dotenv-filename 相对于工作目录及其每个祖先检查。
如果未找到环境文件,这不是错误,除非设置了 dotenv-required。
加载的变量是环境变量,而不是 just 变量,因此必须在配方和反引号中使用 $VARIABLE_NAME 访问。
如果设置了 dotenv-override,环境文件中的变量将覆盖现有的环境变量。
例如,如果你的 .env 文件包含:
# a comment, will be ignored
DATABASE_ADDRESS=localhost:6379
SERVER_PORT=1337
并且你的 justfile 包含:
set dotenv-load
serve:
@echo "Starting server with database $DATABASE_ADDRESS on port $SERVER_PORT…"
./server --database $DATABASE_ADDRESS --port $SERVER_PORT
just serve 将输出:
$ just serve
Starting server with database localhost:6379 on port 1337…
./server --database $DATABASE_ADDRESS --port $SERVER_PORT
export 设置导致所有 just 变量作为环境变量导出。默认为 false。
set export
a := "hello"
@foo b:
echo $a
echo $b
$ just foo goodbye
hello
goodbye
如果 positional-arguments 为 true,配方参数将作为位置参数传递给命令。对于逐行配方,参数 $0 将是配方的名称。
例如,运行这个配方:
set positional-arguments
@foo bar:
echo $0
echo $1
将产生以下输出:
$ just foo hello
foo
hello
当使用与 sh 兼容的 shell 时,例如 bash 或 zsh,$@ 扩展为传递给配方位置参数,从 1 开始。当在双引号内用作 "$@" 时,包含空格的参数将像被双引号引用一样传递。也就是说,"$@" 等同于 "$1" "$2"… 当没有位置参数时,"$@" 和 $@ 扩展为空(即,它们被移除)。
这个示例配方将把参数逐行打印在单独的行上:
set positional-arguments
@test *args='':
bash -c 'while (( "$#" )); do echo - $1; shift; done' -- "$@"
使用 两个 参数运行它:
$ just test foo "bar baz"
- foo
- bar baz
位置参数也可以通过 [positional-arguments] 属性1.29.0 在每个配方的基础上启用:
[positional-arguments]
@foo bar:
echo $0
echo $1
请注意,PowerShell 处理位置参数的方式与其他 shell 不同,因此启用位置参数很可能会破坏使用 PowerShell 的配方。
如果使用 PowerShell 7.4 或更高版本,-CommandWithArgs 标志将使位置参数按预期工作:
set shell := ['pwsh.exe', '-CommandWithArgs']
set positional-arguments
print-args a b c:
Write-Output @($args[1..($args.Count - 1)])
shell 设置控制用于调用配方行和反引号的命令。Shebang 配方不受影响。默认 shell 是 sh -cu。
# use python3 to execute recipe lines and backticks
set shell := ["python3", "-c"]
# use print to capture result of evaluation
foos := `print("foo" * 4)`
foo:
print("Snake snake snake snake.")
print("{{foos}}")
just 将要执行的命令作为参数传递。许多 shell 需要一个额外的标志,通常是 -c,来让它们评估第一个参数。
just 在 Windows 上默认使用 sh。要在 Windows 上使用不同的 shell,请使用 windows-shell:
set windows-shell := ["powershell.exe", "-NoLogo", "-Command"]
hello:
Write-Host "Hello, world!"
查看 powershell.just 以获取在所有平台上使用 PowerShell 的 justfile。
set windows-powershell 使用旧的 powershell.exe 二进制文件,不再推荐。请参阅上面的 windows-shell 设置,以获取更灵活的控制 Windows 上使用哪个 shell 的方法。
just 在 Windows 上默认使用 sh。要改用 powershell.exe,请将 windows-powershell 设置为 true。
set windows-powershell := true
hello:
Write-Host "Hello, world!"
set shell := ["python3", "-c"]
set shell := ["bash", "-uc"]
set shell := ["zsh", "-uc"]
set shell := ["fish", "-c"]
set shell := ["nu", "-c"]
如果你想将默认表格模式更改为 light:
set shell := ['nu', '-m', 'light', '-c']
Nushell 是用 Rust 编写的,支持 Windows / macOS 和 Linux 的跨平台。
紧接在配方之前的注释将出现在 just --list 中:
# build stuff
build:
./bin/build
# test stuff
test:
./bin/test
$ just --list
Available recipes:
build # build stuff
test # test stuff
[doc] 属性可用于设置或抑制配方的文档注释:
# This comment won't appear
[doc('Build stuff')]
build:
./bin/build
# This one won't either
[doc]
test:
./bin/test
$ just --list
Available recipes:
build # Build stuff
test
表达式支持各种运算符和函数调用,这些表达式可以用于赋值、默认配方参数以及配方体 {{…}} 替换内部。
tmpdir := `mktemp -d`
version := "0.2.7"
tardir := tmpdir / "awesomesauce-" + version
tarball := tardir + ".tar.gz"
config := quote(config_dir() / ".project-config")
publish:
rm -f {{tarball}}
mkdir {{tardir}}
cp README.md *.c {{ config }} {{tardir}}
tar zcvf {{tarball}} {{tardir}}
scp {{tarball}} me@server.com:release/
rm -rf {{tarball}} {{tardir}}
+ 运算符返回左操作数与右操作数连接的结果:
foobar := 'foo' + 'bar'
逻辑运算符 && 和 || 可用于合并字符串值1.37.0,类似于 Python 的 and 和 or。这些运算符将空字符串 '' 视为 false,将所有其他字符串视为 true。
这些运算符目前不稳定。
&& 运算符在左操作数为空字符串时返回空字符串,否则返回右操作数:
foo := '' && 'goodbye' # ''
bar := 'hello' && 'goodbye' # 'goodbye'
|| 运算符在左操作数非空时返回左操作数,否则返回右操作数:
foo := '' || 'goodbye' # 'goodbye'
bar := 'hello' || 'goodbye' # 'hello'
/ 运算符可用于用斜杠连接两个字符串:
foo := "a" / "b"
$ just --evaluate foo
a/b
请注意,即使已经存在一个 /,也会添加一个 /:
foo := "a/"
bar := foo / "b"
$ just --evaluate bar
a//b
也可以构造绝对路径1.5.0:
foo := / "b"
$ just --evaluate foo
/b
/ 运算符使用 / 字符,即使在 Windows 上也是如此。因此,应避免将 / 运算符与使用通用命名约定 (UNC) 的路径一起使用,即以 \? 开头的路径,因为 UNC 路径不支持正斜杠。
{{要编写包含 {{ 的配方,请使用 {{{{:
braces:
echo 'I {{{{LOVE}} curly braces!'
(不匹配的 }} 会被忽略,因此不需要转义。)
另一种选择是将所有要转义的文本放在插值内部:
braces:
echo '{{'I {{LOVE}} curly braces!'}}'
还有一种选择是使用 {{ "{{" }}:
braces:
echo 'I {{ "{{" }}LOVE}} curly braces!'
支持 '单引号'、"双引号" 和 '''三引号''' 字符串字面量。与配方体不同,字符串内部不支持 {{…}} 插值。
双引号字符串支持转义序列:
carriage-return := "\r"
double-quote := "\""
newline := "\n"
no-newline := "\
"
slash := "\\"
tab := "\t"
unicode-codepoint := "\u{1F916}"
$ just --evaluate
"arriage-return := "
double-quote := """
newline := "
"
no-newline := ""
slash := "\"
tab := " "
unicode-codepoint := "🤖"
Unicode 字符转义序列 \u{…}1.36.0 最多接受六个十六进制数字。
字符串可以包含换行符:
single := '
hello
'
double := "
goodbye
"
单引号字符串不识别转义序列:
escapes := '\t\n\r\"\\'
$ just --evaluate
escapes := "\t\n\r\"\\"
支持由三个单引号或双引号分隔的缩进版本的单引号和双引号字符串。缩进字符串行会剥离前导换行符,以及所有非空白行共有的前导空白:
# this string will evaluate to `foo\nbar\n`
x := '''
foo
bar
'''
# this string will evaluate to `abc\n wuv\nxyz\n`
y := """
abc
wuv
xyz
"""
与未缩进的字符串类似,缩进的双引号字符串处理转义序列,而缩进的单引号字符串忽略转义序列。转义序列处理在取消缩进之后进行。取消缩进算法不考虑转义序列产生的空白或换行符。
以 x 为前缀的字符串会被 shell 扩展1.27.0:
foobar := x'~/$FOO/${BAR}'
| 值 | 替换 |
|---|---|
$VAR | 环境变量 VAR 的值 |
${VAR} | 环境变量 VAR 的值 |
${VAR:-DEFAULT} | 环境变量 VAR 的值,如果 VAR 未设置则为 DEFAULT |
前导 ~ | 当前用户主目录的路径 |
前导 ~USER | USER 主目录的路径 |
此扩展在编译时执行,因此不能使用来自 .env 文件的变量和导出的 just 变量。但是,这允许 shell 扩展字符串用于诸如设置和导入路径等位置,这些位置不能依赖于 just 变量和 .env 文件。
以 f 为前缀的字符串是格式化字符串1.44.0:
name := "world"
message := f'Hello, {{name}}!'
格式化字符串可以包含由 {{…}} 分隔的插值,其中包含表达式。格式化字符串求值为连接的字符串片段和求值后的表达式。
使用 {{{{ 在格式化字符串中包含字面量 {{:
foo := f'I {{{{LOVE} curly braces!'
通常,如果命令返回非零退出状态,执行将停止。要在命令失败后继续执行,请在命令前加上 -:
foo:
-cat foo
echo 'Done!'
$ just foo
cat foo
cat: foo: No such file or directory
echo 'Done!'
Done!
just 提供了许多内置函数,用于表达式,包括配方体 {{…}} 替换、赋值和默认参数值。
所有以 _directory 结尾的函数都可以缩写为 _dir。所以 home_directory() 也可以写成 home_dir()。此外,invocation_directory_native() 可以缩写为 invocation_dir_native()。
arch() — 指令集架构。可能的值有:"aarch64"、"arm"、"asmjs"、"hexagon"、"mips"、"msp430"、"powerpc"、"powerpc64"、"s390x"、"sparc"、"wasm32"、"x86"、"x86_64" 和 "xcore"。num_cpus()1.15.0 - 逻辑 CPU 数量。os() — 操作系统。可能的值有:"android"、"bitrig"、"dragonfly"、"emscripten"、"freebsd"、"haiku"、"ios"、"linux"、"macos"、"netbsd"、"openbsd"、 和 。os_family() — 操作系统家族;可能的值有:"unix" 和 "windows"。例如:
system-info:
@echo "This is an {{arch()}} machine".
$ just system-info
This is an x86_64 machine
os_family() 函数可用于创建在各种操作系统上工作的跨平台 justfile。有关示例,请参阅 cross-platform.just 文件。
shell(command, args...)1.27.0 返回 shell 脚本 command 的标准输出,带有零个或多个位置参数 args。用于解释 command 的 shell 与用于评估配方行的 shell 相同,并且可以通过 set shell := […] 更改。command 作为第一个参数传递,因此如果命令是 'echo $@',完整的命令行,使用默认 shell 命令 sh -cu 和 args 'foo' 和 'bar' 将是:
'sh' '-cu' 'echo $@' 'echo $@' 'foo' 'bar'
这是为了使 $@ 按预期工作,并且 $1 引用第一个参数。$@ 不包括第一个位置参数,该参数预期是正在运行的程序的名称。
# arguments can be variables or expressions
file := '/sys/class/power_supply/BAT0/status'
bat0stat := shell('cat $1', file)
# commands can be variables or expressions
command := 'wc -l'
output := shell(command + ' "$1"', 'main.c')
# arguments referenced by the shell command must be used
empty := shell('echo', 'foo')
full := shell('echo $1', 'foo')
error := shell('echo $1')
# Using python as the shell. Since `python -c` sets `sys.argv[0]` to `'-c'`,
# the first "real" positional argument will be `sys.argv[2]`.
set shell := ["python3", "-c"]
olleh := shell('import sys; print(sys.argv[2][::-1])', 'hello')
env(key)1.15.0 — 检索名称为 key 的环境变量,如果不存在则中止。
home_dir := env('HOME')
test: echo "{{home_dir}}"
$ just /home/user1
env(key, default)1.15.0 — 检索名称为 key 的环境变量,如果不存在则返回 default。
env_var(key) — env(key) 的已弃用别名。
env_var_or_default(key, default) — env(key, default) 的已弃用别名。
可以使用 || 运算符为环境变量空值替换默认值,该运算符目前不稳定:
set unstable
foo := env('FOO', '') || 'DEFAULT_VALUE'
require(name)1.39.0 — 在 PATH 环境变量的目录中搜索可执行文件 name 并返回其完整路径,如果不存在名为 name 的可执行文件则中止并报错。
bash := require("bash")
@test: echo "bash: '{{bash}}'"
$ just
bash: '/bin/bash'
which(name)1.39.0 — 在 PATH 环境变量的目录中搜索可执行文件 name 并返回其完整路径,如果不存在名为 name 的可执行文件则返回空字符串。目前不稳定。
set unstable
bosh := which("bosh")
@test: echo "bosh: '{{bosh}}'"
$ just
bosh: ''
is_dependency() - 如果当前配方作为另一个配方的依赖项运行,而不是直接运行,则返回字符串 true,否则返回字符串 false。invocation_directory() - 检索调用 just 时当前目录的绝对路径,在 just 在执行命令之前更改它(chdir)之前。在 Windows 上,invocation_directory() 使用 cygpath 将调用目录转换为与 Cygwin 兼容的以 / 分隔的路径。使用 invocation_directory_native() 返回所有平台上的原义调用目录。例如,要对“当前目录”(从用户/调用者的角度来看)下的文件调用 rustfmt,请使用以下规则:
rustfmt:
find {{invocation_directory()}} -name \*.rs -exec rustfmt {} \;
或者,如果你的命令需要从当前目录运行,你可以使用(例如):
build:
cd {{invocation_directory()}}; ./some_script_that_needs_to_be_run_from_here
invocation_directory_native() - 检索调用 just 时当前目录的绝对路径,在 just 在执行命令之前更改它(chdir)之前。justfile() - 检索当前 justfile 的路径。justfile_directory() - 检索当前 justfile 的父目录的路径。例如,运行相对于当前 justfile 位置的命令:
script:
{{justfile_directory()}}/scripts/some_script
source_file()1.27.0 - 检索当前源文件的路径。source_directory()1.27.0 - 检索当前源文件的父目录的路径。source_file() 和 source_directory() 在根 justfile 中的行为与 justfile() 和 justfile_directory() 相同,但在从导入或子模块内部调用时,将分别返回当前 import 或 mod 源文件的路径和目录。
just_executable() - just 可执行文件的绝对路径。例如:
executable:
@echo The executable is at: {{just_executable()}}
GitHub Actions 官方文档查询助手 - 精准解答 CI/CD 工作流问题
45,200 周安装
Microsoft Teams自动化指南:通过Rube MCP实现频道消息、聊天与会议管理
72 周安装
Electrobun 最佳实践:TypeScript + Bun 跨平台桌面应用开发指南
72 周安装
ATXP Memory:AI代理记忆管理工具 - 云端备份与本地向量搜索
72 周安装
Brave Search Spellcheck API:智能拼写检查与查询纠正,提升搜索准确性
72 周安装
Amazon竞品分析器 - 自动化抓取ASIN数据,深度分析竞争对手定价、规格与评论
72 周安装
qa-use:AI驱动开发工作流的端到端测试与浏览器自动化工具
72 周安装
"solaris""windows"