Last active
January 23, 2022 02:32
-
-
Save mike-weiner/9d0cf41f47e796ea91beb9ea153992b5 to your computer and use it in GitHub Desktop.
A bash script that uses the GitHub CLI and JQ to parse and print specific information about open Issues or PRs using .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Function that will print requirements if the user passes in the -help flag as the first argument | |
function help | |
{ | |
echo "Parameters are: " | |
echo "[Required]: search-term" | |
} | |
# Check for '-help' flag | |
if [ $1 == "-help" ]; then | |
help | |
exit 0 | |
fi | |
# Store the filename that the user passed in | |
sarch_term=$1 | |
# https://cli.github.com/manual/ | |
# https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests | |
# Parse open GitHub issues that contain the search-term | |
gh issue list --json assignees,number,title,url | \ | |
jq -jr '.[] | select(any(.; .title | contains("'${sarch_term}'"))) | "\n", "Issue #", .number, "\n\t", .title, "\n\t", "Assignees:", (.assignees[] | " ", .login), "\n\t", .url, "\n\n"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output format: