Skip to content

Commit 446fc3b

Browse files
committed
feat: added --create-repos-md option
1 parent 748e11d commit 446fc3b

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

distribution/bin/cclist

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1-
#! /usr/bin/env bash
1+
#!/usr/bin/env bash
22

3-
aws codecommit list-repositories --query 'repositories[].repositoryName' --output text | xargs -n1
3+
if [ "$1" = "--create-repos-md" ]; then
4+
# Create repos.md file with boilerplate text
5+
echo "# AWS CodeCommit Repositories
6+
7+
This document lists the CodeCommit repositories available in the current AWS account and region.
8+
9+
" > REPOS.md
10+
11+
# Get list of repositories
12+
repos=$(aws codecommit list-repositories --query 'repositories[*].repositoryName' --output text)
13+
14+
# Loop through repositories and add details to repos.md
15+
for repo in $repos; do
16+
# Get repository description
17+
description=$(aws codecommit get-repository --repository-name "$repo" --query 'repositoryMetadata.description' --output text)
18+
19+
# If description is None, set it to "No description available"
20+
if [ "$description" = "None" ]; then
21+
description="No description available"
22+
fi
23+
24+
# Append repository details to repos.md
25+
echo "## $repo" >> REPOS.md
26+
echo "" >> REPOS.md
27+
echo "Description: $description" >> REPOS.md
28+
echo "" >> REPOS.md
29+
done
30+
31+
# No output to stdout
32+
else
33+
# Original functionality: list repositories to stdout
34+
aws codecommit list-repositories --query 'repositories[].repositoryName' --output text | xargs -n1
35+
fi

0 commit comments

Comments
 (0)