-
-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider building and packaging the Shlink CLI as a static binary #1527
Comments
For a bit more clarity, I am trying to script the creation of short URLs on the CLI. My shlink is running on another server, is it true that the current CLI needs to ran where the app is deployed? If true then it seems the only way to interact with shlink on the CLI is via the REST API with curl or something. |
Unfortunately yes. Shlink's CLI, the way it is created right now, does not interact with Shlink's API, but its internals, so it cannot be extracted as it is into a separated tool. Also, there's no way to statically build a binary with the technologies currently used for Shlink. If you are an expert on go/rust or similar, it would be amazing to have such tool. I would be able to support on the API integration as much as needed. |
It would be nice to have such a project under the shlinkio org even if you are the maintainer or not. I would love to contribute if I had free time. I'll add this to the long list of projects on my TODO 😄 |
If you just need a CLI tool to create, list and delete short URLs, this will do just fine: SHLINK_HOST=https://example.com
SHLINK_API_KEY=foobar
shlink () {
BASE_URL="${SHLINK_HOST}/rest/v3/short-urls"
if [[ "$1" == "delete" ]] && [[ -n "$2" ]]
then
curl -s -X 'DELETE' -H 'accept: application/problem+json' -H "X-Api-Key: ${SHLINK_API_KEY}" \
"${BASE_URL}/${2}" | \
jq
elif [[ -z "$1" ]]
then
curl -s -X 'GET' -H 'accept: application/json' -H "X-Api-Key: ${SHLINK_API_KEY}" \
"${BASE_URL}?orderBy=dateCreated-DESC" | \
jq -r '.shortUrls.data[] | .shortUrl + " -> " + .longUrl'
elif [[ "$1" != "help" ]] && [[ "$1" != "--help" ]]
then
curl -s -H "Content-Type: application/json" \
"${BASE_URL}/shorten?apiKey=${SHLINK_API_KEY}&format=txt&longUrl=${1}"
echo ""
else
echo "shlink"
echo "shlink <target-url>"
echo "shlink delete <uuid>"
return 2
fi
} Just put it in your
|
Summary
Hi 👋🏼
It would be great if the shlink CLI (https://shlink.io/documentation/command-line-interface/entry-point/) could be written as such that it would be compiled and packaged as a static binary.
The main benefits would be for the CLI to be packaged for various OS distributions. Imagine being able to run
brew install shlink-cli
orpacman -S shlink-cli
or whatever.I don't know if this would be possible in its current form and maybe a Go / Rust based CLI tool to interact with the shlink API might be better suited for static binaries.
Anyways, thanks for hearing me out.
The text was updated successfully, but these errors were encountered: