41 lines
841 B
Bash
41 lines
841 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
group=${args[group]:?}
|
||
|
|
||
|
_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 // ""')
|
||
|
|
||
|
if [[ -n "$hook" ]]; then
|
||
|
install_args+=("--hook=$hook")
|
||
|
fi
|
||
|
|
||
|
install_args+=("$type")
|
||
|
|
||
|
if [[ -n "$pipe" ]]; then
|
||
|
install_args+=("--pipe=$pipe")
|
||
|
fi
|
||
|
|
||
|
if [[ $source = \$* ]]
|
||
|
then
|
||
|
source=$(eval "echo $source")
|
||
|
fi
|
||
|
install_args+=("$source")
|
||
|
|
||
|
install_args+=("$(eval "echo $target")")
|
||
|
|
||
|
autoinstall "${install_args[@]}"
|
||
|
done
|