2024-02-23 18:30:56 +00:00
# CLI
Since Version 2.2, Random Bunny contains a command line interface (CLI).
2024-04-19 18:30:12 +01:00
## Downloads
2024-07-26 16:53:30 +01:00
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.
2024-04-19 18:30:12 +01:00
We currently support:
- Linux (x64)
- Windows (x64)
- macOS (x64, Arm64\*)
The git repository can also be cloned and ran via `yarn build` and `yarn start` .
2024-07-26 16:53:30 +01:00
You can produce the binary using the `yarn package` command. This creates the binaries in the `./bin` folder.
2024-04-19 18:30:12 +01:00
> **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.
2024-02-23 18:30:56 +00:00
## Default Output
By default, the command will fetch a random image from `r/rabbits` and return it in a human-readable output.
```
2024-07-26 16:53:30 +01:00
$ random-bunny
2024-02-23 18:30:56 +00:00
Archived = false
Downvotes = 0
Hidden = false
Permalink = /r/Rabbits/comments/1av1rg9/cute_baby_bun/
Subreddit = Rabbits
Subreddit Subscribers = 486084
Title = Cute baby bun
Upvotes = 211
Url = https://i.redd.it/sfz0srdrimjc1.png
```
## Help
The command also includes a help option in case you are stuck.
```
2024-07-26 16:53:30 +01:00
$ random-bunny --help
2024-02-23 18:30:56 +00:00
# or
2024-07-26 16:53:30 +01:00
$ random-bunny -h
2024-02-23 18:30:56 +00:00
Usage: random-bunny [options]
Get a random image url from a subreddit of your choosing
Options:
-V, --version output the version number
-s, --subreddit < subreddit > The subreddit to search (default: "rabbits")
-j, --json Output as JSON
-q, --query-metadata Include query metadata in result
2024-06-22 10:09:55 +01:00
-o < file > Output to file
2024-02-23 18:30:56 +00:00
--sort < sort > Sort by (choices: "hot", "new", "top", default: "hot")
2024-07-26 16:53:30 +01:00
--limit < limit > The amount of posts to fetch from the reddit api (default: 100)
2024-02-23 18:30:56 +00:00
-h, --help display help for command
```
## JSON output
You can also convert the output into JSON, if you need to input it to another program.
```bash
2024-07-26 16:53:30 +01:00
$ random-bunny --json
2024-02-23 18:30:56 +00:00
# or
2024-07-26 16:53:30 +01:00
$ randon-bunny -j
2024-02-23 18:30:56 +00:00
{"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"}
```
## Sort
You can also choose the sorting option which reddit will use to return the available posts to randomise from.
This defaults to "hot". The valid options are "hot", "new", and "top".
```
2024-07-26 16:53:30 +01:00
$ random-bunny --sort hot
$ random-bunny --sort new
$ random-bunny --sort top
2024-02-23 18:30:56 +00:00
```
## Subreddit
You can change the subreddit which the command fetches from.
This defaults to "rabbits"
```
2024-07-26 16:53:30 +01:00
$ random-bunny --subreddit rabbits
$ random-bunny -s horses
2024-02-23 18:30:56 +00:00
```
2024-06-22 10:09:55 +01:00
## Output to file
If you'd rather send the output to a file, you can supply the `-o` flag.
```
$ randombunny -o ~/Desktop/output.txt
```
2024-07-26 16:53:30 +01:00
## 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
```