#!/bin/bash # milestone-list.sh - List milestones on GitHub or Gitea # Usage: milestone-list.sh [-s ] set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$SCRIPT_DIR/detect-platform.sh" # Parse arguments # Usage-error contract (R4, 2026-08-28): usage errors print to STDERR and exit 2, # distinct from provider, credential, and verification failures (exit 1). usage_error() { echo "Error: $*" >&2 echo "Usage: milestone-list.sh [-s ] (see --help)" >&2 exit 2 } STATE="open" while [[ $# -gt 0 ]]; do case $1 in -s|--state) [[ $# -ge 2 ]] || usage_error "option $1 requires a value" STATE="$2" shift 2 ;; -h|--help) echo "Usage: milestone-list.sh [-s ]" echo "" echo "Options:" echo " -s, --state Filter by state: open, closed, all (default: open)" echo " -h, --help Show this help" exit 0 ;; *) usage_error "unknown option: $1" ;; esac done detect_platform >/dev/null if [[ "$PLATFORM" == "github" ]]; then gh api "/repos/{owner}/{repo}/milestones?state=$STATE" --jq '.[] | "\(.title) (\(.state)) - \(.open_issues) open, \(.closed_issues) closed"' elif [[ "$PLATFORM" == "gitea" ]]; then REPO_ARGS=$(get_gitea_repo_args) || { echo "Error: Could not resolve Gitea repo/login for remote host" >&2 exit 1 } tea milestone list $REPO_ARGS else echo "Error: Unknown platform" exit 1 fi