src/recipe/lang/Python/rawstr4c.md
RAWSTR_pl_python:global-variable-only-header:hextrue[[index]]
url = "@url@"
default = true
grep -A 2 'index' @f@ | sed -n 's/^url = "\(.*\)"/\1/p'
为什么不用 Select-String,原因见: https://github.com/RubyMetric/chsrc/pull/328#issuecomment-3695577870
还有另外一个好处:如果 [[index]] 配置被写入了多次,可以这样检查出来
我们倾向于使用脚本而非命令,因为内容较长,便于用户检查到底执行了什么内容。
$lines = Get-Content @f@;
for($index=0; $index -lt $lines.Count; $index++) {
if($lines[$index] -match '^\[\[index\]\]$') {
$lines[$index..($index+3)]
}
}
@sed@ '/^\[\[index\]\]$/,/^default = true$/{s|^url = ".*"$|url = "@url@"|;}' @f@
powershell -Command "$content = Get-Content '@f@'; $content = $content -replace '^url = \".*\"$', 'url = \"@url@\"'; $content | Set-Content '@f@'"
grep -q '^\[\[index]]$' @f@
powershell -Command "if (Get-Content @f@ | Select-String '^\[\[index\]\]$') { exit 0 } else { exit 1 }"
rye_config[[sources]]
name = "@1@"
url = "@2@"