Skip to content

Instantly share code, notes, and snippets.

@mike-weiner
Last active January 23, 2022 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mike-weiner/9d0cf41f47e796ea91beb9ea153992b5 to your computer and use it in GitHub Desktop.
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 .
#!/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"'
@mike-weiner
Copy link
Author

mike-weiner commented Jan 22, 2022

Output format:

Issue #<issue-number>:
	<title-of-issue>
	Assignees: <username-1> <username-2> <username-3>
	<url-of-issue>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment