Add abra.sh with common commands #4

Merged
ammaratef45 merged 2 commits from Zigzagill/shlink:abra-sh into main 2026-02-24 04:50:07 +00:00

49
abra.sh Normal file
View File

@ -0,0 +1,49 @@
#!/bin/bash
list_api_keys() {
shlink api-key:list
}
generate_api_key() {
# TODO: add --expiration-date (optionally)?
Zigzagill marked this conversation as resolved Outdated

nit: we can generate a key without a name, not a good practice though so maybe a warning instead of an error? 😆

nit: we can generate a key without a name, not a good practice though so maybe a warning instead of an error? 😆
KEY_NAME=$1
echo "Generating new key..."
if [ -z "$KEY_NAME" ]; then
shlink api-key:generate
return
fi
shlink api-key:generate --name $KEY_NAME
}
rename_api_key() {
OLD_NAME=$1
NEW_NAME=$2
if [ -z "$OLD_NAME" ]; then
echo "No key name(s) provided!"
return
fi
if [ -z "$NEW_NAME" ]; then
echo "New key name not provided!"
return
fi
echo "Renaming key..."
shlink api-key:rename $OLD_NAME $NEW_NAME
}
disable_api_key() {
KEY_NAME=$1
if [ -z "$KEY_NAME" ]; then
echo "Key name not provided!"
fi
echo "Disabling key..."
shlink api-key:disable --by-name $KEY_NAME
}