dirsql 0.3.121 → 0.3.123
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/docs/reference/cli.md +19 -0
- package/docs/reference/path-tables.md +33 -0
- package/package.json +11 -11
package/docs/reference/cli.md
CHANGED
|
@@ -151,6 +151,25 @@ uses**, so behavior is identical to `POST /query` by construction:
|
|
|
151
151
|
statements; dirsql separately never modifies the files it indexes — see
|
|
152
152
|
[Read-only by design](../explanation#read-only-by-design).
|
|
153
153
|
|
|
154
|
+
#### `--on-file <command>`
|
|
155
|
+
|
|
156
|
+
Attach a parser to every [path-table](./path-tables.md#parsing-rows-with-on-file)
|
|
157
|
+
in the query, so each matched file yields the rows the command prints (a JSON
|
|
158
|
+
array of row objects) instead of the stat columns:
|
|
159
|
+
|
|
160
|
+
```sh
|
|
161
|
+
dirsql query "SELECT title, author FROM './posts/*.md'" \
|
|
162
|
+
--on-file 'extract.py {path}'
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
The command follows the [`on-file` hook contract](./hooks.md#on-file) — argv
|
|
166
|
+
splitting, `{path}`/`{root}` placeholders, per-file failure isolation, and the
|
|
167
|
+
timeout. The parser's output is the whole schema; the stat columns are not
|
|
168
|
+
reachable on a parsed path-table. `--on-file` may be given **at most once** (a
|
|
169
|
+
repeat is an error pointing at config files) and never touches config-declared
|
|
170
|
+
tables. It is a `query`-only flag — server mode rejects it as an unknown
|
|
171
|
+
argument.
|
|
172
|
+
|
|
154
173
|
Errors print the same diagnostic the HTTP `{"error": …}` body carries —
|
|
155
174
|
config failures, SQL errors, rejected reads, hook failures, timeouts — to
|
|
156
175
|
stderr, with exit code `1`.
|
|
@@ -114,6 +114,39 @@ SELECT path FROM './docs/*.md' WHERE content LIKE '%deprecated%';
|
|
|
114
114
|
A file that cannot be read, or is not valid UTF-8, yields `NULL` content rather
|
|
115
115
|
than failing the query.
|
|
116
116
|
|
|
117
|
+
## Parsing rows with `--on-file`
|
|
118
|
+
|
|
119
|
+
By default a path-table's columns are the stat columns above — one row per
|
|
120
|
+
file. When you want *one row per record inside* each file, attach a parser with
|
|
121
|
+
the `dirsql query` flag [`--on-file`](/reference/cli):
|
|
122
|
+
|
|
123
|
+
```sh
|
|
124
|
+
dirsql query "SELECT title, author FROM './posts/*.md'" \
|
|
125
|
+
--on-file 'extract.py {path}'
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The command runs once per matched file and prints a JSON array of row objects,
|
|
129
|
+
exactly like a declared table's [`on-file` hook](/reference/hooks) — same argv
|
|
130
|
+
splitting, same `{path}`/`{root}` placeholders, same timeout. Its output *is*
|
|
131
|
+
the table:
|
|
132
|
+
|
|
133
|
+
- **The parser supplies the whole schema.** Columns are inferred from the keys
|
|
134
|
+
across the emitted rows. The stat columns (`path`, `size`, …) are **not**
|
|
135
|
+
reachable on a parsed path-table — a parser that wants the path emits it (it
|
|
136
|
+
has `{path}`). The two modes stay cleanly separate.
|
|
137
|
+
- **Failures are isolated per file.** A file whose parser fails (spawn, non-zero
|
|
138
|
+
exit, timeout, or no output) or whose output is not a JSON array of rows
|
|
139
|
+
contributes no rows; a one-line warning naming the file goes to stderr and the
|
|
140
|
+
scan continues. The schema is inferred from the files that did parse.
|
|
141
|
+
- **The skip rules still apply.** A parsed scan honors the same `node_modules`
|
|
142
|
+
/`.git`/`ignore` rules a stat scan does (see below).
|
|
143
|
+
|
|
144
|
+
`--on-file` applies to **every** path-table in the query and may be given **at
|
|
145
|
+
most once**. For different parsers per file set, define named tables in a
|
|
146
|
+
`.dirsql.toml` with their own `on-file` keys and pass it with `-c` — the flag
|
|
147
|
+
never touches config-declared tables. It is a `query`-subcommand flag; server
|
|
148
|
+
mode does not accept it.
|
|
149
|
+
|
|
117
150
|
## Freshness and scope
|
|
118
151
|
|
|
119
152
|
A path-table is scanned when the statement runs, so it always reflects the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dirsql",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.123",
|
|
4
4
|
"description": "Ephemeral SQL index over a local directory",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://github.com/thekevinscott/dirsql",
|
|
@@ -212,15 +212,15 @@
|
|
|
212
212
|
]
|
|
213
213
|
},
|
|
214
214
|
"optionalDependencies": {
|
|
215
|
-
"@dirsql/lib-linux-x64-gnu": "0.3.
|
|
216
|
-
"@dirsql/lib-linux-arm64-gnu": "0.3.
|
|
217
|
-
"@dirsql/lib-darwin-x64": "0.3.
|
|
218
|
-
"@dirsql/lib-darwin-arm64": "0.3.
|
|
219
|
-
"@dirsql/lib-win32-x64-msvc": "0.3.
|
|
220
|
-
"@dirsql/cli-linux-x64-gnu": "0.3.
|
|
221
|
-
"@dirsql/cli-linux-arm64-gnu": "0.3.
|
|
222
|
-
"@dirsql/cli-darwin-x64": "0.3.
|
|
223
|
-
"@dirsql/cli-darwin-arm64": "0.3.
|
|
224
|
-
"@dirsql/cli-win32-x64-msvc": "0.3.
|
|
215
|
+
"@dirsql/lib-linux-x64-gnu": "0.3.123",
|
|
216
|
+
"@dirsql/lib-linux-arm64-gnu": "0.3.123",
|
|
217
|
+
"@dirsql/lib-darwin-x64": "0.3.123",
|
|
218
|
+
"@dirsql/lib-darwin-arm64": "0.3.123",
|
|
219
|
+
"@dirsql/lib-win32-x64-msvc": "0.3.123",
|
|
220
|
+
"@dirsql/cli-linux-x64-gnu": "0.3.123",
|
|
221
|
+
"@dirsql/cli-linux-arm64-gnu": "0.3.123",
|
|
222
|
+
"@dirsql/cli-darwin-x64": "0.3.123",
|
|
223
|
+
"@dirsql/cli-darwin-arm64": "0.3.123",
|
|
224
|
+
"@dirsql/cli-win32-x64-msvc": "0.3.123"
|
|
225
225
|
}
|
|
226
226
|
}
|