Update documentation
All checks were successful
Test / build (push) Successful in 8s

This commit is contained in:
Ethan Lane 2024-07-26 16:53:30 +01:00 committed by Vylpes
parent 21b45ecb35
commit 657bc7df59
2 changed files with 29 additions and 12 deletions

View file

@ -4,7 +4,7 @@ Since Version 2.2, Random Bunny contains a command line interface (CLI).
## Downloads ## Downloads
The project can be downloaded as a binary for your system via the [GitHub Releases](https://github.com/Vylpes/random-bunny/releases) or [Gitea Releases](https://gitea.vylpes.xyz/RabbitLabs/random-bunny/releases) page. The project can be downloaded as a binary for your system via the [GitHub Releases](https://github.com/Vylpes/random-bunny/releases) or [Forgejo Releases](https://git.vylpes.xyz/RabbitLabs/random-bunny/releases) page.
We currently support: We currently support:
- Linux (x64) - Linux (x64)
@ -13,6 +13,8 @@ We currently support:
The git repository can also be cloned and ran via `yarn build` and `yarn start`. The git repository can also be cloned and ran via `yarn build` and `yarn start`.
You can produce the binary using the `yarn package` command. This creates the binaries in the `./bin` folder.
> **NOTE:** We are aware of a bug in the macOS Arm64 builds failing to execute. For now you're still able to use the x64 builds under Rosetta fine. This will hopefully be fixed in a future release. > **NOTE:** We are aware of a bug in the macOS Arm64 builds failing to execute. For now you're still able to use the x64 builds under Rosetta fine. This will hopefully be fixed in a future release.
## Default Output ## Default Output
@ -20,7 +22,7 @@ The git repository can also be cloned and ran via `yarn build` and `yarn start`.
By default, the command will fetch a random image from `r/rabbits` and return it in a human-readable output. By default, the command will fetch a random image from `r/rabbits` and return it in a human-readable output.
``` ```
$ randombunny $ random-bunny
Archived = false Archived = false
Downvotes = 0 Downvotes = 0
@ -38,11 +40,11 @@ Url = https://i.redd.it/sfz0srdrimjc1.png
The command also includes a help option in case you are stuck. The command also includes a help option in case you are stuck.
``` ```
$ randombunny --help $ random-bunny --help
# or # or
$ randombunny -h $ random-bunny -h
Usage: random-bunny [options] Usage: random-bunny [options]
@ -55,6 +57,7 @@ Options:
-q, --query-metadata Include query metadata in result -q, --query-metadata Include query metadata in result
-o <file> Output to file -o <file> Output to file
--sort <sort> Sort by (choices: "hot", "new", "top", default: "hot") --sort <sort> Sort by (choices: "hot", "new", "top", default: "hot")
--limit <limit> The amount of posts to fetch from the reddit api (default: 100)
-h, --help display help for command -h, --help display help for command
``` ```
@ -63,11 +66,11 @@ Options:
You can also convert the output into JSON, if you need to input it to another program. You can also convert the output into JSON, if you need to input it to another program.
```bash ```bash
$ randombunny --json $ random-bunny --json
# or # or
$ randonbunny -j $ randon-bunny -j
{"Archived":false,"Downs":0,"Hidden":false,"Permalink":"/r/Rabbits/comments/1av1rg9/cute_baby_bun/","Subreddit":"Rabbits","SubredditSubscribers":486085,"Title":"Cute baby bun","Ups":210,"Url":"https://i.redd.it/sfz0srdrimjc1.png"} {"Archived":false,"Downs":0,"Hidden":false,"Permalink":"/r/Rabbits/comments/1av1rg9/cute_baby_bun/","Subreddit":"Rabbits","SubredditSubscribers":486085,"Title":"Cute baby bun","Ups":210,"Url":"https://i.redd.it/sfz0srdrimjc1.png"}
``` ```
@ -79,9 +82,9 @@ You can also choose the sorting option which reddit will use to return the avail
This defaults to "hot". The valid options are "hot", "new", and "top". This defaults to "hot". The valid options are "hot", "new", and "top".
``` ```
$ randombunny --sort hot $ random-bunny --sort hot
$ randombunny --sort new $ random-bunny --sort new
$ randomBunny --sort top $ random-bunny --sort top
``` ```
@ -92,8 +95,8 @@ You can change the subreddit which the command fetches from.
This defaults to "rabbits" This defaults to "rabbits"
``` ```
$ randombunny --subreddit rabbits $ random-bunny --subreddit rabbits
$ randombunny -s horses $ random-bunny -s horses
``` ```
## Output to file ## Output to file
@ -103,3 +106,17 @@ If you'd rather send the output to a file, you can supply the `-o` flag.
``` ```
$ randombunny -o ~/Desktop/output.txt $ randombunny -o ~/Desktop/output.txt
``` ```
## Reddit API Return Limits
You can also limit the amount the posts the script requests from the Reddit API
using the `--limit` option.
This defaults to 100. This accepts any number between 1 and 100.
Please note limiting the calls to less than 100 will give a higher chance of
the script not finding any valid image post to return.
```
$ random-bunny --limit 50
```

View file

@ -33,7 +33,7 @@ console.log(result);
### `randomBunny()` ### `randomBunny()`
Returns a `json string` for a random post. Accepts 2 arguments: `subreddit`, and `sortby` ('new', 'hot', 'top') Returns a `json string` for a random post. Accepts 3 arguments: `subreddit`, `sortby` ('new', 'hot', 'top'), and `limit` (1-100, default 100)
The json string which gets returned consists of: The json string which gets returned consists of:
- archived - archived