#!/bin/bash

# NOTE: by default all issues will be displayed to the console.
#
# USAGE: <script-name> <ISSUE_STATUS> ADDITIONAL_ARGS
#   where ISSUE_STATUS is the status to filter by
#   where ADDITIONAL_ARGS are other args passed to the 'gh issue list' command such as '--web'
#
# NOTE: You can specify ISSUE_STATUS by itself but If you specify ADDITIONAL_ARGS you must first specify ISSUE_STATUS

VALUES='
2.9.7,spring-cloud-dataflow-build
2.9.7,spring-cloud-dataflow-common
2.7.7,spring-cloud-deployer
2.7.7,spring-cloud-deployer-local
2.7.7,spring-cloud-deployer-cloudfoundry
2.7.7,spring-cloud-deployer-kubernetes
1.7.7,spring-cloud-common-security-config
2.8.7,spring-cloud-skipper
3.2.7,spring-cloud-dataflow-ui
2.9.7,spring-cloud-dataflow
'
ISSUE_STATUS="${1:-all}"

for VALUE in $VALUES;
  do
    MILESTONE=$(echo $VALUE | cut -f1 -d,)
    REPO=$(echo $VALUE | cut -f2 -d,)
    TEMPLATE="{{range .}}spring-cloud/$REPO#{{.number}} {{.title}}{{\"\n\"}}{{end}}"
    gh issue list --repo spring-cloud/$REPO --search milestone:$MILESTONE --state $ISSUE_STATUS $2
done;
