dbcat 0.0.9 → 0.0.11
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 +22 -0
- package/package.json +1 -1
- package/src/index.ts +8 -5
package/README.md
CHANGED
|
@@ -65,6 +65,28 @@ Pipe to `less -R` for scrollable output with colors:
|
|
|
65
65
|
bunx dbcat ./data.db --full | less -R
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
+
### Git diffable
|
|
69
|
+
|
|
70
|
+
Do these things to make git use `dbcat` to diff your sqlite databases:
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
# .gitattributes
|
|
74
|
+
*.sqlite binary diff=dbcat
|
|
75
|
+
*.db binary diff=dbcat
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
git config diff.lockb.textconv "bunx dbcat --full"
|
|
80
|
+
git config diff.lockb.binary true
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
And now you should be able to use
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
git diff ./data.db
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
|
|
68
90
|
## Requirements
|
|
69
91
|
|
|
70
92
|
[Bun](https://bun.sh) v1.3+
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -146,7 +146,7 @@ function displayQueryResult(rows: Record<string, unknown>[]) {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
async function readStdin(): Promise<string | null> {
|
|
149
|
-
if (process.stdin.isTTY
|
|
149
|
+
if (process.stdin.isTTY) {
|
|
150
150
|
return null;
|
|
151
151
|
}
|
|
152
152
|
|
|
@@ -162,11 +162,14 @@ function parseArgs() {
|
|
|
162
162
|
const args = process.argv.slice(2);
|
|
163
163
|
let input: string | undefined;
|
|
164
164
|
let full = false;
|
|
165
|
+
let help = false
|
|
165
166
|
let json: false | "plain" | "color" = false;
|
|
166
167
|
|
|
167
168
|
for (const arg of args) {
|
|
168
169
|
if (arg === "--full" || arg === "-f") {
|
|
169
170
|
full = true;
|
|
171
|
+
} else if (arg === "--help" || arg === "-h") {
|
|
172
|
+
help = true;
|
|
170
173
|
} else if (arg === "--json") {
|
|
171
174
|
json = "plain";
|
|
172
175
|
} else if (arg === "--json=color") {
|
|
@@ -176,7 +179,7 @@ function parseArgs() {
|
|
|
176
179
|
}
|
|
177
180
|
}
|
|
178
181
|
|
|
179
|
-
return { input, full, json };
|
|
182
|
+
return { input, full, json, help };
|
|
180
183
|
}
|
|
181
184
|
|
|
182
185
|
const DEFAULT_LIMIT = 100;
|
|
@@ -204,9 +207,9 @@ function outputJson(data: unknown, color: boolean) {
|
|
|
204
207
|
}
|
|
205
208
|
|
|
206
209
|
async function main() {
|
|
207
|
-
const { input, full, json } = parseArgs();
|
|
210
|
+
const { input, full, json, help } = parseArgs();
|
|
208
211
|
|
|
209
|
-
if (!input && !process.env.DATABASE_URL) {
|
|
212
|
+
if ((!input && !process.env.DATABASE_URL) || help) {
|
|
210
213
|
showUsageAndExit();
|
|
211
214
|
}
|
|
212
215
|
|
|
@@ -243,7 +246,7 @@ async function main() {
|
|
|
243
246
|
|
|
244
247
|
let sql: InstanceType<typeof Bun.SQL>;
|
|
245
248
|
try {
|
|
246
|
-
sql = createConnection(connectionInput, { readonly:
|
|
249
|
+
sql = createConnection(connectionInput, { readonly: process.stdin.isTTY });
|
|
247
250
|
} catch (error) {
|
|
248
251
|
console.error("Failed to connect:");
|
|
249
252
|
console.error(error instanceof Error ? error.message : String(error));
|