Skip to content

Commit

Permalink
Improvement: Add Description and Set Default Title with Optional Argu…
Browse files Browse the repository at this point in the history
…ment (#884)

* feat: add description

(cherry picked from commit 61c7964)

* feat: set default title and update title argument optional

(cherry picked from commit 2fc559b)
  • Loading branch information
atzzCokeK authored Oct 17, 2023
1 parent e9dfe43 commit 212044b
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions commands/conversions/inputs-to-markdown-link.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,32 @@
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Simple Markdown Link Generator
# @raycast.description Quickly and simply generate a markdown formatted link with your specified URL and title.
# @raycast.mode silent
# @raycast.packageName Conversions

# 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

0 comments on commit 212044b

Please sign in to comment.