diff --git a/README.md b/README.md
index 1756621..41cc4eb 100644
--- a/README.md
+++ b/README.md
@@ -93,7 +93,7 @@ For more usage examples, see the **[Examples Guide](docs/examples.md)**.
Sarin supports environment variables, CLI flags, and YAML files. When the same option is specified in multiple sources, the following priority order applies:
```
-YAML (Highest) > CLI Flags > Environment Variables (Lowest)
+CLI Flags (Highest) > YAML > Environment Variables (Lowest)
```
For detailed documentation on all configuration options (URL, method, timeout, concurrency, headers, cookies, proxy, etc.), see the **[Configuration Guide](docs/configuration.md)**.
@@ -106,9 +106,9 @@ Sarin supports Go templates in URL paths, methods, bodies, headers, params, cook
```sh
sarin -U "http://example.com/users/{{ fakeit_UUID }}" -r 1000 -c 10 \
- -V "RequestID={{ fakeit_UUID }}" \
- -H "X-Request-ID: {{ .Values.RequestID }}" \
- -B '{"request_id": "{{ .Values.RequestID }}"}'
+ -V "REQUEST_ID={{ fakeit_UUID }}" \
+ -H "X-Request-ID: {{ .Values.REQUEST_ID }}" \
+ -B '{"request_id": "{{ .Values.REQUEST_ID }}"}'
```
For the complete templating guide and functions reference, see the **[Templating Guide](docs/templating.md)**.
diff --git a/docs/configuration.md b/docs/configuration.md
index 69de6d0..51d555d 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -5,7 +5,7 @@ Sarin supports environment variables, CLI flags, and YAML files. However, they a
When the same option is specified in multiple sources, the following priority order applies:
```
-YAML (Highest) > CLI Flags > Environment Variables (Lowest)
+CLI Flags (Highest) > YAML > Environment Variables (Lowest)
```
Use `-s` or `--show-config` to see the final merged configuration before sending requests.
@@ -14,8 +14,8 @@ Use `-s` or `--show-config` to see the final merged configuration before sending
> **Note:** For CLI flags with `string / []string` type, the flag can be used once with a single value or multiple times to provide multiple values.
-| Name | YAML | CLI | ENV | Default | Description |
-| --------------------------- | ----------------------------------- | --------------------------------------------- | -------------------------------- | ------- | ---------------------------- |
+| Name | YAML | CLI | ENV | Default | Description |
+| --------------------------- | ----------------------------------- | -------------------------------------------- | -------------------------------- | ------- | ---------------------------- |
| [Help](#help) | - | `-help` / `-h` | - | - | Show help message |
| [Version](#version) | - | `-version` / `-v` | - | - | Show version and build info |
| [Show Config](#show-config) | `showConfig`
(boolean) | `-show-config` / `-s`
(boolean) | `SARIN_SHOW_CONFIG`
(boolean) | `false` | Show merged configuration |
@@ -43,36 +43,65 @@ Use `-s` or `--show-config` to see the final merged configuration before sending
Show help message.
+```sh
+sarin -help
+```
+
## Version
Show version and build information.
+```sh
+sarin -version
+```
+
## Show Config
Show the final merged configuration before sending requests.
+```sh
+sarin -show-config
+```
+
## Config File
Path to configuration file(s). Supports local paths and remote URLs.
-If multiple config files are specified, they are merged in order. Later files override earlier ones.
+**Priority Rules:**
+
+1. **CLI flags** (`-f`) have highest priority, processed left to right (rightmost wins)
+2. **Included files** (via `configFile` property) are processed with lower priority than their parent
+3. **Environment variable** (`SARIN_CONFIG_FILE`) has lowest priority
**Example:**
```yaml
# config2.yaml
configFile: /config4.yaml
+url: http://from-config2.com
```
```sh
SARIN_CONFIG_FILE=/config1.yaml sarin -f /config2.yaml -f https://example.com/config3.yaml
```
-In this example, all 4 config files are read and merged with the following priority:
+**Resolution order (lowest to highest priority):**
-```
-config3.yaml > config2.yaml > config4.yaml > config1.yaml
-```
+| Source | File | Priority |
+| ------------------------ | ------------ | -------- |
+| ENV (SARIN_CONFIG_FILE) | config1.yaml | Lowest |
+| Included by config2.yaml | config4.yaml | ↑ |
+| CLI -f (first) | config2.yaml | ↑ |
+| CLI -f (second) | config3.yaml | Highest |
+
+**Why this order?**
+
+- `config1.yaml` comes from ENV → lowest priority
+- `config2.yaml` comes from CLI → higher than ENV
+- `config4.yaml` is included BY `config2.yaml` → inherits position below its parent
+- `config3.yaml` comes from CLI after `config2.yaml` → highest priority
+
+If all four files define `url`, the value from `config3.yaml` wins.
## URL
@@ -94,7 +123,7 @@ sarin -U "http://example.com/users/{{ fakeit_UUID }}" -r 1000 -c 10
## Method
-HTTP method(s). If multiple values are provided, Sarin cycles through them randomly for each request. Supports [templating](templating.md).
+HTTP method(s). If multiple values are provided, Sarin cycles through them in order, starting from a random index for each request. Supports [templating](templating.md).
**YAML example:**
@@ -167,7 +196,7 @@ Skip TLS certificate verification.
## Body
-Request body. If multiple values are provided, Sarin cycles through them randomly for each request. Supports [templating](templating.md).
+Request body. If multiple values are provided, Sarin cycles through them in order, starting from a random index for each request. Supports [templating](templating.md).
**YAML example:**
@@ -196,7 +225,7 @@ SARIN_BODY='{"product": "car"}'
## Params
-URL query parameters. If multiple values are provided for a key, Sarin cycles through them randomly for each request. Supports [templating](templating.md).
+URL query parameters. If multiple values are provided for a key, Sarin cycles through them in order, starting from a random index for each request. Supports [templating](templating.md).
**YAML example:**
@@ -226,7 +255,7 @@ SARIN_PARAM="key1=value1"
## Headers
-HTTP headers. If multiple values are provided for a key, Sarin cycles through them randomly for each request. Supports [templating](templating.md).
+HTTP headers. If multiple values are provided for a key, Sarin cycles through them in order, starting from a random index for each request. Supports [templating](templating.md).
**YAML example:**
@@ -256,7 +285,7 @@ SARIN_HEADER="key1: value1"
## Cookies
-HTTP cookies. If multiple values are provided for a key, Sarin cycles through them randomly for each request. Supports [templating](templating.md).
+HTTP cookies. If multiple values are provided for a key, Sarin cycles through them in order, starting from a random index for each request. Supports [templating](templating.md).
**YAML example:**
@@ -286,7 +315,7 @@ SARIN_COOKIE="key1=value1"
## Proxy
-Proxy URL(s). If multiple values are provided, Sarin cycles through them randomly for each request.
+Proxy URL(s). If multiple values are provided, Sarin cycles through them in order, starting from a random index for each request.
Supported protocols: `http`, `https`, `socks5`, `socks5h`
diff --git a/docs/examples.md b/docs/examples.md
index 05b3222..717ad5a 100644
--- a/docs/examples.md
+++ b/docs/examples.md
@@ -175,8 +175,8 @@ url: http://example.com/search
requests: 1000
concurrency: 10
params:
- query: test
- limit: "10"
+ query: "test"
+ limit: 10
```
@@ -198,7 +198,7 @@ requests: 1000
concurrency: 10
params:
id: "{{ fakeit_IntRange 1 1000 }}"
- fields: name,email
+ fields: "name,email"
```
diff --git a/docs/templating.md b/docs/templating.md
index 05ae26f..6a35faf 100644
--- a/docs/templating.md
+++ b/docs/templating.md
@@ -532,7 +532,7 @@ These functions are powered by [gofakeit](https://github.com/brianvoe/gofakeit)
| Function | Description | Example |
| ------------------------------------- | ------------------------------- | --------------------------------------------------------------- |
| `fakeit_Digit` | Single random digit | `"0"` |
-| `fakeit_DigitN(n uint)` | Generate `n` random digits | `{{ fakeit_DigitN 5 }}` → `"0136459948"` |
+| `fakeit_DigitN(n uint)` | Generate `n` random digits | `{{ fakeit_DigitN 5 }}` → `"71364"` |
| `fakeit_Letter` | Single random letter | `"g"` |
| `fakeit_LetterN(n uint)` | Generate `n` random letters | `{{ fakeit_LetterN 10 }}` → `"gbRMaRxHki"` |
| `fakeit_Lexify(pattern string)` | Replace `?` with random letters | `{{ fakeit_Lexify "?????@??????.com" }}` → `"billy@mister.com"` |