2024-01-09 15:48:11 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
group=${args[group]:?}
|
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" \
|
|
|
|
'.autoinstall | map(select(.group == $group)) | '"$1" \
|
|
|
|
"$XDG_CONFIG_HOME/autoinstall.toml"
|
|
|
|
}
|
|
|
|
|
|
|
|
#length=$(_config_query "length")
|
|
|
|
_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")")
|
|
|
|
|
|
|
|
autoinstall "${install_args[@]}"
|
|
|
|
done
|