# b-doc

A Rust CLI tool that health-checks a list of hosts by making HTTP GET requests and reports results as JSON lines.

## Installation

```sh
cargo install --path .
```

Or install from crates.io:

```sh
cargo install b-doc
```

Or build from source:

```sh
cargo build --release
./target/release/b-doc --help
```

## Usage

```
Usage: b-doc [OPTIONS]

Options:
  -f, --file-name <FILE_NAME>
          Path to JSON hosts file (reads from stdin if omitted)
  -t, --timeout <TIMEOUT>
          Timeout in seconds for each request represented as an integer [default: 10]
  -c, --concurrent-tests <CONCURRENT_TESTS>
          Limit concurrent tests [default: 10]
  -h, --help
          Print help
  -V, --version
          Print version

```

### With a file

```sh
b-doc -f tests/inputs/hosts_01.json
```

### Piped input

```sh
echo '{"hosts":[{"name":"Example","url":"https://example.com"}]}' | b-doc
```

```sh
cat hosts.json | b-doc
```

## Input format

A JSON object with a `hosts` array:

```json
{
  "hosts": [
    { "name": "My Service", "url": "https://my-service.example.com/health" },
    { "name": "Another", "url": "https://another.example.com/api" }
  ]
}
```

## Output format

One JSON object per host, printed line-by-line:

```json
{"ok":true,"host":{"url":"https://example.com","name":"Example"},"time_in_ms":342,"description":"Status code between 200 and 299"}
```

| Field        | Description                                     |
|--------------|-------------------------------------------------|
| `ok`         | `true` if status was 200–299, `false` otherwise |
| `host`       | The original `url` and `name` from input         |
| `time_in_ms` | Request duration in milliseconds                 |
| `description`| Success message or error detail                  |

## Exit codes

| Code | Meaning                                      |
|------|----------------------------------------------|
| 0    | Program ran successfully (regardless of host results) |
| 1    | CLI error (bad file, stdin is a terminal, etc.)       |
