tools/autoinstall/run_command.sh

49 lines
1 KiB
Bash
Raw Normal View History

2024-01-09 15:48:11 +00:00
#!/usr/bin/env bash
group=${args[group]:?}
2024-03-22 21:14:13 +00:00
file=${args[--file]:-}
2024-01-12 01:40:58 +00:00
clean=${args[--clean]:-}
2024-01-09 15:48:11 +00:00
_config_query() {
tomlq -c --arg group "$group" \
2024-02-01 14:51:33 +00:00
'.autoinstall | map(select(.groups + ["all"] | contains([$group]))) | '"$1" \
2024-03-22 21:14:13 +00:00
"$file"
2024-01-09 15:48:11 +00:00
}
_config_query ".[]" | while read -r entry; do
install_args=()
type=$(echo "$entry" | jq -r '.type')
source=$(echo "$entry" | jq -r '.source')
target=$(echo "$entry" | jq -r '.target')
hook=$(echo "$entry" | jq -r '.hook // ""')
pipe=$(echo "$entry" | jq -r '.pipe // ""')
2024-01-12 01:40:58 +00:00
completions=$(echo "$entry" | jq -r '.completions // ""')
2024-01-09 15:48:11 +00:00
if [[ -n "$hook" ]]; then
install_args+=("--hook=$hook")
fi
2024-01-12 01:40:58 +00:00
if [[ -n "$clean" ]]; then
install_args+=("--clean")
fi
2024-01-09 15:48:11 +00:00
install_args+=("$type")
if [[ -n "$pipe" ]]; then
install_args+=("--pipe=$pipe")
fi
2024-01-12 01:40:58 +00:00
if [[ -n "$completions" ]]; then
install_args+=("--completions=$completions")
fi
2024-01-09 15:48:11 +00:00
if [[ $source = \$* ]]
then
source=$(eval "echo $source")
fi
install_args+=("$source")
install_args+=("$(eval "echo $target")")
2024-03-22 21:14:13 +00:00
"$0" "${install_args[@]}"
2024-01-09 15:48:11 +00:00
done