#! /usr/bin/env nix-shell
#! nix-shell -i bash -p curl htmlq

# echo "Fetching cookie and CSRF token..."
# form=$(curl --silent --location --junk-session-cookies --cookie-jar /tmp/wifionice "https://login.wifionice.de/en/" --resolve login.wifionice.de:443:10.101.64.10 -i | htmlq "input")

# keys=$(htmlq "input" --attribute "name" <<< "$form")
# values=$(htmlq "input" --attribute "value" <<< "$form")
# payload=$(paste --delimiters="=" <(echo "$keys") <(echo "$values") | tr "\n" "&")

# echo "Payload: \"$payload\""
# echo "POSTing payload..."

# curl --cookie /tmp/wifionice "https://login.wifionice.de/en/" --resolve login.wifionice.de:443:10.101.64.10 -d "$payload"

def main [
  interface: string
  type: string
] {
  let form = curl --silent --location --junk-session-cookies --cookie-jar /tmp/wifionice 'https://login.wifionice.de/en/' --resolve 'login.wifionice.de:443:10.101.64.10' -i | htmlq 'input';
  # TODO
}
