nostr-bray 1.10.0 → 1.11.0
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/dist/cli.js +18 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -138,6 +138,7 @@ Environment:
|
|
|
138
138
|
NOSTR_RELAYS Comma-separated relay URLs
|
|
139
139
|
NWC_URI / NWC_URI_FILE Nostr Wallet Connect URI
|
|
140
140
|
TOR_PROXY SOCKS5h proxy URL
|
|
141
|
+
NOSTR_BRAY_OUTPUT Default output: "human" (default) or "json"
|
|
141
142
|
|
|
142
143
|
Quick examples:
|
|
143
144
|
nostr-bray whoami # show your npub
|
|
@@ -149,7 +150,8 @@ Quick examples:
|
|
|
149
150
|
nostr-bray shell # interactive mode
|
|
150
151
|
|
|
151
152
|
Flags:
|
|
152
|
-
--json Output raw JSON
|
|
153
|
+
--json Output raw JSON (for piping/scripts)
|
|
154
|
+
--human Force human-readable output
|
|
153
155
|
--help Show help for a command
|
|
154
156
|
|
|
155
157
|
Use 'nostr-bray <command> --help' for detailed help on any command.
|
|
@@ -176,10 +178,21 @@ config.secretKey = '';
|
|
|
176
178
|
config.nwcUri = undefined;
|
|
177
179
|
const masterRelays = await nip65.loadForIdentity(ctx.activeNpub);
|
|
178
180
|
pool.reconfigure(ctx.activeNpub, masterRelays);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
+
// Default output mode from env (CLI-level --json/--human handled per-command)
|
|
182
|
+
const envDefault = process.env.NOSTR_BRAY_OUTPUT === 'json' ? 'json' : 'human';
|
|
183
|
+
/** Resolve output mode for a given set of args */
|
|
184
|
+
function resolveOutputMode(cmdArgs) {
|
|
185
|
+
if (cmdArgs.includes('--json'))
|
|
186
|
+
return 'json';
|
|
187
|
+
if (cmdArgs.includes('--human'))
|
|
188
|
+
return 'human';
|
|
189
|
+
return envDefault;
|
|
190
|
+
}
|
|
191
|
+
// Top-level output mode (for single-command invocations)
|
|
192
|
+
let currentOutputMode = resolveOutputMode(args);
|
|
193
|
+
/** Print JSON or human-readable depending on output mode */
|
|
181
194
|
function out(data, humanFormatter) {
|
|
182
|
-
if (
|
|
195
|
+
if (currentOutputMode === 'json' || !humanFormatter) {
|
|
183
196
|
console.log(JSON.stringify(data, null, 2));
|
|
184
197
|
}
|
|
185
198
|
else {
|
|
@@ -218,6 +231,7 @@ function parseShellLine(line) {
|
|
|
218
231
|
return result;
|
|
219
232
|
}
|
|
220
233
|
async function run(cmdArgs) {
|
|
234
|
+
currentOutputMode = resolveOutputMode(cmdArgs);
|
|
221
235
|
const command = cmdArgs[0];
|
|
222
236
|
/** Require arg or throw */
|
|
223
237
|
function req(index, usage) {
|
package/package.json
CHANGED