#!/usr/bin/env bash

# Safer shell script with these options
# -e          : exit if a command exits with non-zero status
# -u          : exit if an expanded variable does not exist
# -o pipefail : if a command in a pipeline fail, fail the pipeline
#               (e.g this now fails: false | true)
set -euo pipefail

function weather() {
  if [[ $# == 0 ]]; then
    weather :help
    return
  fi

  local url="wttr.in/$1?format=v2"
  echo "Getting weather using url: $url"
  curl "$url"
}

weather "$@"
