@flux-lang/cli 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +157 -0
- package/package.json +4 -3
package/README.md
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# @flux-lang/cli
|
|
2
|
+
|
|
3
|
+
Command-line tools for the **Flux** score language.
|
|
4
|
+
|
|
5
|
+
This package provides the `flux` binary, built on top of `@flux-lang/core`, with:
|
|
6
|
+
|
|
7
|
+
- `flux parse` – parse Flux source files and print their IR as JSON.
|
|
8
|
+
- `flux check` – parse + run basic static checks (grids, neighbors, timers).
|
|
9
|
+
|
|
10
|
+
Flux is a small, declarative language for **procedurally evolving music scores and parts**. See the main repo for the full IR and language spec.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
Global install:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g @flux-lang/cli
|
|
20
|
+
````
|
|
21
|
+
|
|
22
|
+
Project-local (dev) install:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install --save-dev @flux-lang/cli
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
You can also use `npx` without installing globally.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Commands
|
|
33
|
+
|
|
34
|
+
### `flux parse`
|
|
35
|
+
|
|
36
|
+
Parse one or more `.flux` files and print their IR as JSON.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
flux parse example.flux
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
For a single file, the default output is pretty-printed JSON, e.g.:
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"meta": {
|
|
47
|
+
"version": "0.1.0",
|
|
48
|
+
"title": "Example"
|
|
49
|
+
},
|
|
50
|
+
"state": {
|
|
51
|
+
"params": []
|
|
52
|
+
},
|
|
53
|
+
"grids": [],
|
|
54
|
+
"rules": []
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Options:
|
|
59
|
+
|
|
60
|
+
* `--ndjson` – emit **one JSON object per line** `{ "file", "doc" }` (always used when parsing multiple files).
|
|
61
|
+
* `--pretty` – always pretty-print JSON (2-space indent).
|
|
62
|
+
* `--compact` – compact JSON with no extra whitespace.
|
|
63
|
+
|
|
64
|
+
You can also read from stdin using `-`:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
cat example.flux | flux parse -
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
> Note: `-` (stdin) can only be used by itself (not mixed with other file paths).
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
### `flux check`
|
|
75
|
+
|
|
76
|
+
Parse `.flux` files and run basic static checks:
|
|
77
|
+
|
|
78
|
+
* Unknown `grid` references in rule scopes.
|
|
79
|
+
* Unsupported `neighbors.*` methods.
|
|
80
|
+
* Obvious runtime timer issues (`timer(...)` amount must be positive).
|
|
81
|
+
* A light `initRuntimeState` smoke-check to catch obviously invalid IR.
|
|
82
|
+
|
|
83
|
+
Basic usage:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
flux check example.flux
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
If all files are OK:
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
✓ 1 files OK
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
If some fail, diagnostics go to **stderr** and a summary to **stdout**:
|
|
96
|
+
|
|
97
|
+
```text
|
|
98
|
+
# stderr
|
|
99
|
+
example.flux:0:0: Check error: Rule 'oops' references unknown grid 'notAGrid'
|
|
100
|
+
|
|
101
|
+
# stdout
|
|
102
|
+
✗ 1 of 1 files failed checks
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
#### JSON / NDJSON output
|
|
106
|
+
|
|
107
|
+
You can get machine-readable diagnostics via:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
flux check --json example.flux
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
This emits one JSON line per input file:
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{"file":"example.flux","ok":false,"errors":[{"message":"example.flux:0:0: Check error: Rule 'oops' references unknown grid 'notAGrid'"}]}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Using with npm scripts / CI
|
|
122
|
+
|
|
123
|
+
Example `package.json` snippets:
|
|
124
|
+
|
|
125
|
+
```jsonc
|
|
126
|
+
{
|
|
127
|
+
"scripts": {
|
|
128
|
+
"flux:parse": "flux parse src/scores/*.flux",
|
|
129
|
+
"flux:check": "flux check src/scores/*.flux"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
In CI, you can simply run:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
npx flux check src/scores/*.flux
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
and treat a non-zero exit code as a failure.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Relationship to `@flux-lang/core`
|
|
145
|
+
|
|
146
|
+
`@flux-lang/cli` is a thin wrapper around `@flux-lang/core`:
|
|
147
|
+
|
|
148
|
+
* `flux parse` calls `parseDocument` and prints the `FluxDocument` IR.
|
|
149
|
+
* `flux check` uses both the parser and `checkDocument` to validate documents.
|
|
150
|
+
|
|
151
|
+
If you want to embed Flux directly in a tool or runtime, prefer `@flux-lang/core`. If you want to wire Flux into scripts, CI, or quick local checks, use `@flux-lang/cli`.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
MIT – see the LICENSE file in the repo root.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flux-lang/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "CLI tooling for the Flux score language",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Sebastian Suarez-Solis",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"dist",
|
|
17
|
-
"README.md"
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
18
19
|
],
|
|
19
20
|
"scripts": {
|
|
20
21
|
"build": "tsc -p tsconfig.json",
|
|
@@ -31,4 +32,4 @@
|
|
|
31
32
|
"vitest": "^2.1.0",
|
|
32
33
|
"typescript": "^5.6.0"
|
|
33
34
|
}
|
|
34
|
-
}
|
|
35
|
+
}
|