Created
September 22, 2022 15:09
-
-
Save Kshitij09/fa719c38f3b5ea1d0cc1dec0844184fa to your computer and use it in GitHub Desktop.
Utility shell function to perform common operations around Jira Ticket URLs. Currently supports macOS only
This file contains hidden or 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
function sjira() { | |
local __usage=" | |
Usage: sjira GROW-3599 [-poc] | |
Options: | |
-p, --print Print genereated URL | |
-o, --open Open generated URL in browser (Default) | |
-c, --copy Copy generated URL to clipboard | |
" | |
if [ "$#" -lt 1 ]; then | |
echo $__usage | |
return 126; | |
fi | |
local ticket=$(echo $1 | sed -r 's/([A-Za-z]+)-?([0-9]+)/\1-\2/') | |
local url="https://example.atlassian.net/browse/$ticket" | |
opt=${2:-"-o"} | |
case $opt in | |
-p|--print) | |
echo $url | |
;; | |
-o|--open) | |
open $url | |
;; | |
-c|--copy) | |
echo $url | pbcopy | |
;; | |
*) | |
echo "idk ¯\_(ツ)_/¯" | |
;; | |
esac | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment