bruno/packages/bruno-cli/readme.md

94 lines
2.7 KiB
Markdown
Raw Normal View History

2023-02-07 23:15:27 +01:00
# bruno-cli
2023-04-01 10:10:23 +02:00
With Bruno CLI, you can now run your API collections with ease using simple command line commands.
2023-02-07 23:15:27 +01:00
2023-04-01 10:10:23 +02:00
This makes it easier to test your APIs in different environments, automate your testing process, and integrate your API tests with your continuous integration and deployment workflows.
## Installation
2023-04-01 10:10:23 +02:00
To install the Bruno CLI, use the node package manager of your choice, such as NPM:
2023-04-01 10:10:23 +02:00
```bash
npm install -g @usebruno/cli
```
## Getting started
2023-04-01 10:10:23 +02:00
Navigate to the directory where your API collection resides, and then run:
2023-04-01 10:10:23 +02:00
```bash
2023-04-01 10:25:32 +02:00
bru run
2023-04-01 10:10:23 +02:00
```
2023-04-01 10:10:23 +02:00
This command will run all the requests in your collection. You can also run a single request by specifying its filename:
```bash
2023-04-01 10:25:32 +02:00
bru run request.bru
2023-04-01 10:10:23 +02:00
```
Or run all requests in a collection's subfolder:
2023-02-07 23:15:27 +01:00
```bash
2023-04-01 10:25:32 +02:00
bru run folder
2023-04-01 10:10:23 +02:00
```
If you need to use an environment, you can specify it with the `--env` option:
2023-04-01 10:10:23 +02:00
```bash
2023-04-01 10:25:32 +02:00
bru run folder --env Local
2023-04-01 10:10:23 +02:00
```
If you need to collect the results of your API tests, you can specify the `--output` option:
```bash
bru run folder --output results.json
```
If you need to run a set of requests that connect to peers with both publicly and privately signed certificates respectively, you can add private CA certificates via the `--cacert` option. By default, these certificates will be used in addition to the default truststore:
```bash
bru run folder --cacert myCustomCA.pem
```
If you need to limit the trusted CA to a specified set when validating the request peer, provide them via `--cacert` and in addition use `--ignore-truststore` to disable the default truststore:
```bash
bru run request.bru --cacert myCustomCA.pem --ignore-truststore
```
fix(#2122): add specific error status codes (#2126) * fix: add specific error status codes #2122 This change adds specific exit status codes to identify different problems programatically * feat(#2122): Document the cli exit status codes * Update packages/bruno-cli/src/constants.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/constants.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> --------- Co-authored-by: Andreas Siegel <mail@andreassiegel.de>
2024-06-05 16:59:59 +02:00
## Scripting
Bruno cli returns the following exit status codes:
- `0` -- execution successful
- `1` -- an assertion, test, or request in the executed collection failed
- `2` -- the specified output directory does not exist
- `3` -- the request chain seems to loop endlessly
- `4` -- bru was called outside of a collection root directory
fix(#2122): add specific error status codes (#2126) * fix: add specific error status codes #2122 This change adds specific exit status codes to identify different problems programatically * feat(#2122): Document the cli exit status codes * Update packages/bruno-cli/src/constants.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/constants.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> --------- Co-authored-by: Andreas Siegel <mail@andreassiegel.de>
2024-06-05 16:59:59 +02:00
- `5` -- the specified input file does not exist
- `6` -- the specified environment does not exist
- `7` -- the environment override was not a string or object
- `8` -- an environment override is malformed
- `9` -- an invalid output format was requested
- `255` -- another error occurred
fix(#2122): add specific error status codes (#2126) * fix: add specific error status codes #2122 This change adds specific exit status codes to identify different problems programatically * feat(#2122): Document the cli exit status codes * Update packages/bruno-cli/src/constants.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/constants.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> --------- Co-authored-by: Andreas Siegel <mail@andreassiegel.de>
2024-06-05 16:59:59 +02:00
## Demo
![demo](assets/images/cli-demo.png)
2023-04-01 10:10:23 +02:00
## Support
2023-04-01 10:10:23 +02:00
If you encounter any issues or have any feedback or suggestions, please raise them on our [GitHub repository](https://github.com/usebruno/bruno)
Thank you for using Bruno CLI!
2023-09-04 08:54:18 +02:00
## Changelog
<!-- An absolute link is used here because npm treats links differently -->
fix(#2122): add specific error status codes (#2126) * fix: add specific error status codes #2122 This change adds specific exit status codes to identify different problems programatically * feat(#2122): Document the cli exit status codes * Update packages/bruno-cli/src/constants.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/constants.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> * Update packages/bruno-cli/src/commands/run.js Co-authored-by: Andreas Siegel <mail@andreassiegel.de> --------- Co-authored-by: Andreas Siegel <mail@andreassiegel.de>
2024-06-05 16:59:59 +02:00
See [https://github.com/usebruno/bruno/releases](https://github.com/usebruno/bruno/releases)
2023-04-01 10:10:23 +02:00
## License
[MIT](license.md)