Repository navigation
Expand file tree
/
Copy pathlist-repos.sh
More file actions
executable file
·85 lines (76 loc) · 1.84 KB
/
Copy pathlist-repos.sh
File metadata and controls
executable file
·85 lines (76 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env bash
# List the org's repositories from structure/repos.json.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
usage() {
cat <<'EOF'
Usage: list-repos.sh [options]
Options:
--simulation Only simulation repositories
--no-simulation Only non-simulation repositories
--type TYPE Filter by repos.json type field
--status STATUS Filter by status (active|template|draft|wip|archived)
--lineage LINEAGE Filter by lineage (original|phet|naap)
--json Output JSON
--names Output names only (one per line)
--paths Output local workspace paths
--require-local With --paths, only existing directories
--summary Print catalog summary
-h, --help Show this help
Examples:
list-repos.sh --simulation --names
list-repos.sh --json
list-repos.sh --paths --simulation --require-local
EOF
}
ARGS=()
FORMAT="text"
COMMAND="list"
while [[ $# -gt 0 ]]; do
case "$1" in
--simulation|--no-simulation)
ARGS+=("$1")
shift
;;
--type|--status|--lineage)
ARGS+=("$1" "${2:?Missing value for $1}")
shift 2
;;
--json)
FORMAT="json"
shift
;;
--names)
FORMAT="names"
shift
;;
--paths)
COMMAND="paths"
shift
;;
--require-local)
ARGS+=("--require-local")
shift
;;
--summary)
COMMAND="summary"
shift
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown option: $1" >&2
usage >&2
exit 2
;;
esac
done
if [[ "$COMMAND" == "summary" ]]; then
exec "$SCRIPT_DIR/parse-repos.sh" summary "${ARGS[@]}"
fi
if [[ "$COMMAND" == "paths" ]]; then
exec "$SCRIPT_DIR/parse-repos.sh" paths "${ARGS[@]}"
fi
exec "$SCRIPT_DIR/parse-repos.sh" list --format "$FORMAT" "${ARGS[@]}"