From a9168e3459b3e6e256dbf2ffc5bb88ffd30ada75 Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Sun, 31 Mar 2024 21:07:31 -0500 Subject: [PATCH] docs: Added CLI usage instructions --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index f4df505..cdd24e9 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,38 @@ default, the auto-generated links are adjective-name pairs. You can use UIDs by the `slug_style` variable to `UID`. You can also set the length of those slug by setting the `slug_length` variable. It defaults to 8, and a minimum of 4 is supported. +## CLI usage instructions +The application can be used from the terminal using something like `curl`. In all the examples +below, replace `http://localhost:4567` with where your instance of `chhoto-url` is accessible. + +If you have set up +a password, first do the following to get an authentication cookie and store it in a file. +```bash +curl -X post -d "" -c cookie.txt http://localhost:4567/api/login +``` +You should receive "Correct password!" in case the provided password was correct. For any other +request, please add `-b cookie.txt` to use this authentication cookie. + +To add a link, do +```bash +curl -X POST -d '{"shhortlink":"", "longlink":}' http://localhost:4567/api/new +``` +Send an empty `` if you want it to be auto-generated. The server will reply with the generated shortlink. + +To get a list of all the currently available links as `json`, do +```bash +curl http://localhost:4567/api/all +``` + +To delete a link, do +```bash +curl -X DELETE http://localhost:4567/api/del/ +``` +The server will send a confirmation. + +You can get the version of `chhoto-url` the server is running using `curl http://localhost:4567/api/version` and +get the siteurl using `curl http://localhost:4567/api/siteurl`. + ## Disable authentication If you do not define a password environment variable when starting the docker image, authentication will be disabled.