#!/bin/sh
set -euC

# nfsn-dns-spf DOMAIN NAME [INCLUDE]...

# nfsn-dns-spf "example.com" "mailgun.org"

# Arguments.

domain="$1" ; shift
name="$1" ; shift

# Process.

data="$(
    printf -- "v=spf1"
    for include in "$@"
    do
        printf -- " include:%s" "$include"
    done
    printf -- " -all"
    printf -- "\n"
)"

# Update.

nfsn-dns-update "$domain" "$name" "TXT" '^v=spf1' "$data"