dirsql 0.3.122 → 0.3.124
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/howto/write-a-plugin.md +1 -1
- package/docs/reference/cli.md +25 -3
- package/docs/reference/path-tables.md +33 -0
- package/package.json +11 -11
|
@@ -217,7 +217,7 @@ Discovery is deliberately narrow. Know exactly who does what:
|
|
|
217
217
|
your config still takes ordering precedence
|
|
218
218
|
([composing configs](../reference/config.md#composing-multiple-configs)). When
|
|
219
219
|
you pass no `-c` of your own, the launcher also keeps the
|
|
220
|
-
shipped starter `
|
|
220
|
+
shipped starter `records` table (an internal `--include-default`), so plugins
|
|
221
221
|
**add** tables rather than standing alone. Discovery is **pip/uvx only** for now — the `npx`
|
|
222
222
|
launcher does not yet discover — and is switched off per invocation with
|
|
223
223
|
[`--no-plugin` or `DIRSQL_NO_PLUGIN=1`](../reference/cli.md#plugins).
|
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`.
|
|
@@ -164,8 +183,11 @@ stderr, with exit code `1`.
|
|
|
164
183
|
|
|
165
184
|
## `dirsql init`
|
|
166
185
|
|
|
167
|
-
Writes a starter `.dirsql.toml`
|
|
168
|
-
|
|
186
|
+
Writes a starter `.dirsql.toml` as a scaffold to edit. It does **not**
|
|
187
|
+
duplicate the zero-config floor (`SELECT * FROM './'` already lists every file
|
|
188
|
+
with no config); instead it shows the **escalation**: one named `[[table]]`
|
|
189
|
+
with a glob, a schema, and a real `on-file` hook that pulls structured rows
|
|
190
|
+
out of your files.
|
|
169
191
|
|
|
170
192
|
```bash
|
|
171
193
|
dirsql init
|
|
@@ -206,7 +228,7 @@ installed in the same environment as `dirsql` (`pip install …`, or
|
|
|
206
228
|
loads its fragment — its tables are queryable with zero config edits.
|
|
207
229
|
Installed = active: there is no enable step and no naming convention. The
|
|
208
230
|
fragment is composed *after* your own `-c` configs (so your config takes
|
|
209
|
-
precedence in ordering), and the shipped starter `
|
|
231
|
+
precedence in ordering), and the shipped starter `records` table is preserved.
|
|
210
232
|
|
|
211
233
|
Discovery is **launcher-only** — the standalone `cargo`-installed binary does no
|
|
212
234
|
discovery, and the SDKs never auto-discover (pass a plugin's config explicitly
|
|
@@ -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.124",
|
|
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.124",
|
|
216
|
+
"@dirsql/lib-linux-arm64-gnu": "0.3.124",
|
|
217
|
+
"@dirsql/lib-darwin-x64": "0.3.124",
|
|
218
|
+
"@dirsql/lib-darwin-arm64": "0.3.124",
|
|
219
|
+
"@dirsql/lib-win32-x64-msvc": "0.3.124",
|
|
220
|
+
"@dirsql/cli-linux-x64-gnu": "0.3.124",
|
|
221
|
+
"@dirsql/cli-linux-arm64-gnu": "0.3.124",
|
|
222
|
+
"@dirsql/cli-darwin-x64": "0.3.124",
|
|
223
|
+
"@dirsql/cli-darwin-arm64": "0.3.124",
|
|
224
|
+
"@dirsql/cli-win32-x64-msvc": "0.3.124"
|
|
225
225
|
}
|
|
226
226
|
}
|