xeq 2.4.1

xeq is a cross-platform CLI tool that runs sequences of commands from a single TOML file, making repetitive tasks fast and consistent.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
<div align="center">
<img src="./assets/logo_rounded.png" alt="logo" width="150"/>

# xeq


[![Crates.io](https://img.shields.io/crates/v/xeq)](https://crates.io/crates/xeq)
[![Downloads](https://img.shields.io/crates/d/xeq)](https://crates.io/crates/xeq)
[![License](https://img.shields.io/crates/l/xeq)](LICENSE)
[![Build](https://github.com/opmr0/xeq/actions/workflows/release.yml/badge.svg)](https://github.com/opmr0/xeq/actions)
[![Rust](https://img.shields.io/badge/rust-stable-orange)](https://www.rust-lang.org)

**xeq runs sequences of commands from a single TOML file, making repetitive tasks fast and consistent.**

Every project has a setup ritual. Ten commands, always in the same order, every time. Write them once in a `xeq.toml`, commit it, and anyone on any OS runs the exact same steps with one command.

</div>

---

## Table of Contents


- [Demo]#demo
- [Installation]#installation
- [Quick Start]#quick-start
- [Comparison]#comparison
- [Commands]#commands
- [TOML Format]#toml-format
- [Features]#features
  - [1. Script Options]#1-script-options
  - [2. Variables]#2-variables
  - [3. Arguments]#3-arguments
  - [4. Environment Variables]#4-environment-variables
  - [5. Nested Scripts]#5-nested-scripts
  - [6. Parallel Execution]#6-parallel-execution
  - [7. Global Configuration]#7-global-configuration
  - [8. Events]#8-events
  - [9. Custom Shells]#9-custom-shells
- [CI Usage]#ci-usage
- [Examples]#examples
- [How It Works]#how-it-works
- [Contributing]#contributing
- [License]#license

---

## Demo


![demo](assets/demo.gif)

## Installation


**macOS / Linux**

```bash
curl -sSf https://raw.githubusercontent.com/opmr0/xeq/main/install.sh | sh
```

**Windows (Powershell)**

```powershell
iwr https://raw.githubusercontent.com/opmr0/xeq/main/install.ps1 -UseBasicParsing | iex
```

**Via cargo (Rust package manager)**

```bash
cargo install xeq
```

---

## Quick Start


**1. Create a `xeq.toml` in your project root:**

```toml
[setup]
run = [
    "npm install",
    "npm run build"
]

[dev]
run = ["npm run dev"]
```

**2. Run any script by name:**

```bash
xeq run setup
xeq run dev
```

xeq finds `xeq.toml` in the current directory automatically. Use `xeq init` to generate a starter file.

---

## Comparison


| Feature            | **xeq**              | **Makefile**       | **npm scripts** | **just**     |
| ------------------ | -------------------- | ------------------ | --------------- | ------------ |
| File type          | TOML                 | Makefile           | package.json    | Justfile     |
| Cross-platform     | Yes                  | Mostly Linux/macOS | Yes             | Yes          |
| Validation command | Yes (`xeq validate`) | No                 | No              | No           |
| Variables          | Yes                  | Yes                | Limited         | Yes          |
| Args support       | Yes                  | Limited            | Limited         | Yes          |
| Nested scripts     | Yes (`xeq:`)         | Yes                | No              | Yes          |
| Parallel execution | Yes                  | Yes (`-j`)         | No              | No           |
| .env support       | Yes (auto)           | No                 | No              | Yes (opt-in) |
| Init templates     | Yes (30+)            | No                 | No              | No           |

---

## Commands


### `xeq run <script> [flags]`


Runs a script by name. Commands execute in order. If any command fails, xeq stops unless you pass `--continue-on-err`.

If no script name is given, xeq runs the `default` script defined in your config:

```toml
default = "dev"

[dev]
run = ["npm run dev"]
```

```bash
xeq run        # runs "dev"
xeq run setup
xeq run build --continue-on-err
xeq run dev --quiet
xeq run test --parallel
xeq run create --args my-app
xeq run deploy --args env=prod
```

| Flag                   | Short | Description                                                 |
| ---------------------- | ----- | ----------------------------------------------------------- |
| `--continue-on-err`    | `-C`  | Keep going even if a command fails                          |
| `--quiet`              | `-q`  | Hide xeq's own log messages                                 |
| `--clear`              | `-c`  | Clear the terminal before each command                      |
| `--parallel [threads]` | `-p`  | Run all commands in parallel (default: logical CPU count)   |
| `--args <values...>`   | `-a`  | Pass arguments into the script, positional or `key=value`   |
| `--global`             | `-g`  | Use the globally saved `xeq.toml` instead of the local one  |
| `--dry-run`            | `-d`  | Preview commands without executing them                     |
| `--no-events`          | `-e`  | Disable events for this run                                 |
| `--allow-empty-args`   | `-A`  | Skip errors for missing variables or arguments              |
| `--no-env`             |       | Skip loading the `.env` file                                |
| `--allow-recursion`    |       | Let a script call itself                                    |

**Exit codes:** xeq exits `0` on success and non-zero if any command fails. Use this in CI pipelines or shell scripts to halt on failure.

---

### `xeq init [template]`


Creates a starter `xeq.toml` in the current directory. Will not overwrite an existing file.

```bash
xeq init
xeq init rust
xeq init docker
```

**Available templates:** `android`, `ansible`, `astro`, `aws`, `bun`, `deno`, `django`, `docker`, `dotnet`, `elixir`, `expo`, `fastapi`, `flutter`, `git`, `go`, `hugo`, `java-gradle`, `java-maven`, `kubernetes`, `laravel`, `monorepo`, `nestjs`, `nextjs`, `node`, `python`, `rails`, `react`, `rust`, `svelte`, `tauri`

---

### `xeq validate`


Checks all scripts for errors without running anything.

| Check                               | Flag        |
| ----------------------------------- | ----------- |
| Circular dependencies               | static      |
| Missing `xeq:` targets              | static      |
| `default` script existence          | static      |
| `continue_on_err` + events conflict | static      |
| `parallel_threads` <= 1             | static      |
| `parallel` + `cd`/`xeq:` conflict  | static      |
| `dir` existence                     | static      |
| Undefined `{{@var}}`                | static      |
| `dir` cd permission                 | `--runtime` |
| Unset `{{$VAR}}` env vars           | `--runtime` |
| Command existence                   | `--runtime` |

Add `--runtime` to also validate environment variables and system commands:

```bash
xeq validate
xeq validate --runtime
xeq validate --global
```

---

### `xeq list`


Shows all scripts in your `xeq.toml`, names, descriptions, and commands.

```bash
xeq list
xeq list --global
```

---

### `xeq config [path]`


Saves a `xeq.toml` path globally so you can run it from anywhere.

```bash
xeq config ~/my-scripts/xeq.toml   # save once
xeq config                          # open saved file in your editor
```

---

### `xeq toml`


Prints the full TOML format reference.

---

### Aliases


| Command        | Alias   |
| -------------- | ------- |
| `xeq run`      | `xeq r` |
| `xeq config`   | `xeq c` |
| `xeq init`     | `xeq i` |
| `xeq validate` | `xeq v` |

---

## TOML Format


Each script needs at minimum a `run` array:

```toml
[my-script]
description = "What this script does"
dir = "./my_app"
parallel_threads = 4
options = ["quiet"]
run = [
    "command one",
    "command two"
]
```

- `run` - required, commands to execute in order
- `description` - optional, shown in `xeq list`
- `dir` - optional, working directory (absolute or relative to where xeq is invoked, not where `xeq.toml` lives)
- `parallel_threads` - optional, enables parallel execution with a set thread count
- `options` - optional, baked-in flags. see [Script Options]#1-script-options

Script names are case-sensitive. `Build` and `build` are different scripts.

---

## Features


### 1. Script Options


Bake default behavior into a script so you don't have to pass flags every time:

```toml
[build]
options = ["quiet", "continue_on_err"]
run = ["cargo build", "cargo test"]
```

**Available options:** `quiet`, `clear`, `continue_on_err`, `allow_recursion`, `allow_empty_vars`

CLI flags toggle script options. If `quiet` is baked in and you pass `--quiet`, it turns quiet off for that run.

```bash
xeq run build          # quiet ON  (from TOML)
xeq run build --quiet  # quiet OFF (toggled)
```

---

### 2. Variables


Define reusable values in a `[vars]` block and reference them with `{{@varname}}`:

```toml
[vars]
image = "myapp:latest"
env = "development"

[build]
run = ["docker build -t {{@image}} ."]

[start]
run = ["APP_ENV={{@env}} npm start"]
```

**Local variables** override global ones for a specific script:

```toml
[vars]
image = "myapp:latest"

[build]
vars.image = "myapp:build"
run = ["docker build -t {{@image}} ."]   # uses "myapp:build"

[push]
run = ["docker push {{@image}}"]          # uses "myapp:latest"
```

**Override at runtime** with `--args`:

```bash
xeq run build --args image=myapp:hotfix
```

**Fallback values** use `|` to provide a default if a variable isn't set:

```toml
[build]
run = ["docker build -t {{@image | myapp:latest}} ."]
```

**Resolution order:** `--args` -> local vars -> global vars -> fallback

> If a variable isn't defined and no fallback is set, xeq exits with an error. Pass `--allow-empty-vars` or add `allow_empty_vars` to options to skip this.

---

### 3. Arguments


Use positional placeholders `{{1}}`, `{{2}}` for values that change every run:

```toml
[create]
run = [
    "npm create vite@latest {{1}} -- --template {{2}}",
    "cd {{1}}",
    "npm install"
]
```

```bash
xeq run create --args my-app react
# {{1}} = my-app

# {{2}} = react

```

Mix named and positional args:

```bash
xeq run deploy --args env=production my-app
```

> Missing arguments cause an error. Use `--allow-empty-vars` to skip this.

---

### 4. Environment Variables


Reference environment variables with `{{$VARNAME}}`:

```toml
[deploy]
run = ["deploy --token {{$API_TOKEN}} --env {{$DEPLOY_ENV}}"]
```

xeq loads a `.env` file from the directory where xeq is invoked automatically:

```bash
# .env

API_TOKEN=abc123
DEPLOY_ENV=production
```

Pass `--no-env` to skip loading `.env`.

> Missing env vars cause an error. Use `--allow-empty-vars` to skip this.

---

### 5. Nested Scripts


Call other scripts from within a script using the `xeq:` prefix:

```toml
[install]
run = ["npm install"]

[build]
run = ["npm run build"]

[deploy]
run = [
    "xeq:install",
    "xeq:build",
    "npm run deploy"
]
```

Running `xeq run deploy` runs `install` and `build` first, in order.

> xeq detects circular dependencies and exits. Add `allow_recursion` to options if you intentionally need a script to call itself.

---

### 6. Parallel Execution


Run all commands in a script at the same time:

```toml
[check]
parallel_threads = 4
run = [
    "cargo test",
    "cargo clippy",
    "cargo fmt --check"
]
```

Use `-p` to toggle parallel mode from the CLI, or `-p <threads>` to override the thread count:

```bash
xeq run check         # uses parallel_threads from TOML
xeq run check -p      # uses logical CPU count
xeq run check -p 8    # uses 8 threads
```

> Scripts with `cd` commands or `xeq:` calls cannot run in parallel. `xeq validate` catches this.
> If `parallel_threads` is 1 or less, xeq falls back to sequential execution.

---

### 7. Global Configuration


Save a `xeq.toml` globally to run scripts from any directory:

```bash
xeq config ~/my-scripts/xeq.toml   # save once
xeq run git-cleanup --global        # run from anywhere
xeq list --global                   # list global scripts
```

---

### 8. Events


Run additional commands when a script succeeds or fails:

```toml
[build]
run = ["cargo test", "cargo build"]
on_success = ["echo build passed"]
on_error = ["echo build failed"]
```

> Events cannot be combined with `continue_on_err`.

---

### 9. Custom Shells


Set a shell at the file level to run all commands with:

```toml
shell = "zsh"

[build]
run = ["cargo build", "cargo test"]
```

**Available shells:** `sh`, `bash`, `zsh`, `fish`, `cmd`, `powershell`

Defaults to `sh` on Linux/macOS and `cmd` on Windows.

---

## CI Usage


xeq works well in CI pipelines. Use `xeq validate --runtime` as a pre-flight check to catch missing commands or unset env vars before anything runs.

**GitHub Actions example:**

```yaml
- name: Validate config
  run: xeq validate --runtime

- name: Build
  run: xeq run build

- name: Test
  run: xeq run test
```

xeq exits non-zero on any failure, so your pipeline halts automatically without extra configuration.

---

## Examples

The [`examples/`](./examples) folder has ready-to-use TOML files for common workflows.

| File                  | Description                                 | Features Used                             |
| --------------------- | ------------------------------------------- | ----------------------------------------- |
| `react-tailwind.toml` | Scaffold and run a React + Tailwind project | variables, cd operators                   |
| `nextjs.toml`         | Next.js project setup and pipeline          | nested scripts, variables                 |
| `rust-project.toml`   | Rust checks, build and publish              | parallel, nested scripts                  |
| `docker.toml`         | Docker image and container management       | variables, nested scripts                 |
| `git-workflow.toml`   | Common git operations                       | variables, arguments                      |
| `nested-scripts.toml` | CI pipeline from reusable pieces            | nested scripts                            |
| `env-vars.toml`       | Deploy and notify using env vars            | `{{$VAR}}`, nested scripts                |
| `python-project.toml` | Virtualenv, checks and PyPI publish         | parallel, nested scripts, variables       |
| `database.toml`       | Migrations, seed, dump and restore          | env vars, arguments, nested scripts       |
| `monorepo.toml`       | Multi-package frontend workspace            | parallel, variables, nested scripts       |
| `aws-deploy.toml`     | ECR push and ECS deploy pipeline            | env vars, nested scripts                  |
| `go-project.toml`     | Go build, test and cross-compile            | parallel, nested scripts, variables       |
| `arguments.toml`      | Positional and named arg patterns           | arguments, variables                      |
| `script-options.toml` | Flag toggle mechanic demonstrations         | options, parallel, quiet, continue_on_err |

---

## How It Works

- xeq reads `xeq.toml` from the current directory, or a globally saved path with `--global`
- Commands run through `sh -c` on Linux/macOS and `cmd /C` on Windows by default
- `cd` commands update the working directory for all subsequent commands in that script
- `dir` is resolved relative to where xeq is invoked, not where `xeq.toml` lives
- Variables resolve in order: `--args` -> local vars -> global vars -> fallback
- `.env` is loaded from the invocation directory automatically before any script runs
- Script names are case-sensitive

---

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md).

---

## License

MIT - [LICENSE](LICENSE)