From 2fc559b4b03d6463e08ae0d48848c3df93222a9c Mon Sep 17 00:00:00 2001 From: atzzCokeK Date: Sat, 14 Oct 2023 11:33:31 +0900 Subject: [PATCH] feat: set default title and update title argument optional --- commands/conversions/inputs-to-markdown-link.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/commands/conversions/inputs-to-markdown-link.sh b/commands/conversions/inputs-to-markdown-link.sh index d6b20fd92..28e84e5e1 100755 --- a/commands/conversions/inputs-to-markdown-link.sh +++ b/commands/conversions/inputs-to-markdown-link.sh @@ -9,23 +9,26 @@ # Optional parameters: # @raycast.icon 🔗 -# @raycast.argument1 { "type": "text", "placeholder": "Title" } -# @raycast.argument2 { "type": "text", "placeholder": "URL" } +# @raycast.argument1 { "type": "text", "placeholder": "URL" } +# @raycast.argument2 { "type": "text", "placeholder": "Title (default: Link)", "optional": true } # Description: -# Quickly and simply generate a markdown formatted link with your specified title and URL. +# Quickly and simply generate a markdown formatted link with your specified URL and title. # The generated link is copied to your clipboard for easy pasting. # Documentation: # @raycast.author atzzCokeK # @raycast.authorURL https://github.com/atzzCokeK +URL=$1 +TITLE=${2:-Link} # Use "Link" as default if title is not provided + regex='(https?|ftp|file)://[-[:alnum:]\+&@#/%?=~_|!:,.;]+' -if [[ $2 =~ $regex ]]; then - echo "[$1]($2)" | pbcopy - echo "Copied: [$1]($2)" +if [[ $URL =~ $regex ]]; then + echo "[$TITLE]($URL)" | pbcopy + echo "Copied: [$TITLE]($URL)" else - echo "Invalid URL: $2" + echo "Invalid URL: $URL" exit 1 fi \ No newline at end of file