#!/bin/bash
PROGNAME=${0##*/}
usage() {
  echo "Usage: ${PROGNAME} [-n] [-h]"
}

help_message() {
  cat <<- EOF
	${PROGNAME}
	
	Download nextflow and viash binaries into the 'bin' folder
	$(usage)
	Options:
	-n		Download viash only.
	-h		Display this help message and exit.
	EOF
}

only_viash=false
while getopts ":hn" opt; do
  case ${opt} in
    h ) help_message
        exit 0;
        ;;
    n ) only_viash=true
        ;;
    \? ) >&2 echo "Invalid Option: -${OPTARG}" 1>&2
         help_message
         exit 1;
         ;;
    : )
         >&2 echo "Invalid Option: -${OPTARG} requires an argument" 1>&2
         help_message
         exit 1
         ;;
  esac
done


# get the root of the directory
REPO_ROOT=$(git rev-parse --show-toplevel)

# ensure that the command below is run from the root of the repository
cd "$REPO_ROOT"

curl -fsSL get.viash.io | bash -s -- \
  --registry ghcr.io \
  --organisation viash-io \
  --target_image_source https://github.com/viash-io/viashpy.git \
  --tag develop

