spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / scripts / gh.sh
43 lines · 903 BRaw
1#!/usr/bin/env bash
2set -euo pipefail
3
4# Wrapper around gh CLI that only allows specific subcommands and flags.
5#
6# Usage:
7# ./scripts/gh.sh issue view 123
8# ./scripts/gh.sh issue view 123 --comments
9# ./scripts/gh.sh issue list --state open --limit 20
10# ./scripts/gh.sh search issues "search query" --limit 10
11# ./scripts/gh.sh label list --limit 100
12
13ALLOWED_FLAGS=(--comments --state --limit --label)
14
15SUB1="${1:-}"
16SUB2="${2:-}"
17CMD="$SUB1 $SUB2"
18case "$CMD" in
19 "issue view"|"issue list"|"search issues"|"label list")
20 ;;
21 *)
22 exit 1
23 ;;
24esac
25
26shift 2
27for arg in "$@"; do
28 if [[ "$arg" == -* ]]; then
29 flag="${arg%%=*}"
30 matched=false
31 for allowed in "${ALLOWED_FLAGS[@]}"; do
32 if [[ "$flag" == "$allowed" ]]; then
33 matched=true
34 break
35 fi
36 done
37 if [[ "$matched" == false ]]; then
38 exit 1
39 fi
40 fi
41done
42
43gh "$SUB1" "$SUB2" "$@"