Skip to content

Commit 2e8a014

Browse files
feat: world-class CLI help — per-command --help with examples, quick examples, learn more links
1 parent f377673 commit 2e8a014

2 files changed

Lines changed: 135 additions & 1 deletion

File tree

src/cli.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import { handleDuressConfigure, handleDuressActivate } from './safety/handlers.j
2020
import { handleZapSend, handleZapBalance, handleZapMakeInvoice, handleZapLookupInvoice, handleZapListTransactions, handleZapReceipts, handleZapDecode } from './zap/handlers.js'
2121
import { handleDecode, handleEncodeNpub, handleEncodeNote, handleEncodeNprofile, handleEncodeNevent, handleVerify, handleEncrypt, handleDecrypt, handleCount, handleFetch, handleKeyPublic, handleEncodeNsec, handleFilter, handleNipList, handleNipShow } from './util/handlers.js'
2222

23+
import { getCommandHelp } from './help.js'
24+
2325
const args = process.argv.slice(2)
2426
const command = args[0]
2527

@@ -29,6 +31,12 @@ if (!command || command === 'serve') {
2931
process.exit(0)
3032
}
3133

34+
// Per-command help: `nostr-bray post --help`
35+
if (args.includes('--help') && command && command !== 'help' && command !== '--help' && command !== '-h') {
36+
const help = getCommandHelp(command)
37+
if (help) { console.log(help); process.exit(0) }
38+
}
39+
3240
const HELP = `nostr-bray — Sovereign Nostr identities for AI agents
3341
3442
Usage: nostr-bray [command] [args]
@@ -130,7 +138,23 @@ Environment:
130138
NOSTR_SECRET_KEY_FILE Path to secret key file
131139
NOSTR_RELAYS Comma-separated relay URLs
132140
NWC_URI / NWC_URI_FILE Nostr Wallet Connect URI
133-
TOR_PROXY SOCKS5h proxy URL`
141+
TOR_PROXY SOCKS5h proxy URL
142+
143+
Quick examples:
144+
nostr-bray whoami # show your npub
145+
nostr-bray post "gm nostr" # publish a note
146+
nostr-bray persona work # derive work identity
147+
nostr-bray dm abc123... "secret message" # send encrypted DM
148+
nostr-bray decode npub1... # decode any nip19 entity
149+
nostr-bray nips # browse official NIPs
150+
nostr-bray shell # interactive mode
151+
152+
Use 'nostr-bray <command> --help' for detailed help on any command.
153+
154+
Learn more:
155+
Guide: https://github.com/forgesworn/bray/blob/main/docs/guide.md
156+
Examples: https://github.com/forgesworn/bray/tree/main/examples
157+
npm: https://www.npmjs.com/package/nostr-bray`
134158

135159
if (command === 'help' || command === '--help' || command === '-h') {
136160
console.log(HELP)

0 commit comments

Comments
 (0)