Skip to content

Commit 250974c

Browse files
rolandmargclaude
andcommitted
feat: add --help, --version, and improved bare invocation
Adds help/version commands so `lorebook --help`, `lorebook help`, and bare `lorebook` all show useful usage info instead of erroring. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 612796a commit 250974c

File tree

1 file changed

+47
-2
lines changed

1 file changed

+47
-2
lines changed

src/index.ts

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { resolveEntries, loadConfig } from './resolve';
33
import { buildInjection, type InjectionEntry } from './inject';
44
import type { HookInput, HookOutput } from './hook';
55

6+
const VERSION = '0.2.0';
7+
68
const command = process.argv[2];
79

810
switch (command) {
@@ -15,9 +17,19 @@ switch (command) {
1517
case 'list':
1618
await handleList();
1719
break;
20+
case 'help':
21+
case '--help':
22+
case '-h':
23+
printHelp();
24+
break;
25+
case 'version':
26+
case '--version':
27+
case '-v':
28+
console.log(`lorebook ${VERSION}`);
29+
break;
1830
default:
19-
console.error('Usage: lorebook <match|test|list>');
20-
process.exit(1);
31+
printHelp();
32+
process.exit(command ? 1 : 0);
2133
}
2234

2335
function runMatch(
@@ -149,3 +161,36 @@ async function handleList(): Promise<void> {
149161
const disabled = entries.length - enabled;
150162
console.log(`${entries.length} entries (${enabled} enabled, ${disabled} disabled)`);
151163
}
164+
165+
function printHelp(): void {
166+
console.log(`lorebook ${VERSION} — keyword-triggered context injection for AI coding agents
167+
168+
Usage: lorebook <command>
169+
170+
Commands:
171+
test "<prompt>" Show which entries match a prompt
172+
list List all entries and their status
173+
match Hook mode — reads JSON from stdin, outputs injection (used by Claude Code hook)
174+
help Show this help
175+
176+
Options:
177+
--help, -h Show this help
178+
--version, -v Show version
179+
180+
Entry format:
181+
Markdown files with YAML frontmatter in:
182+
.claude/lorebook/ (project, higher priority)
183+
~/.claude/lorebook/ (global)
184+
185+
Frontmatter fields:
186+
keys: [word, ...] Required. Triggers on ANY keyword match.
187+
exclude_keys: [...] Suppresses if ANY match.
188+
priority: <number> Higher = injected first. Default: 0
189+
enabled: <boolean> Default: true
190+
191+
Config:
192+
lorebook.json in .claude/lorebook/ or .claude/ (project or global):
193+
{ "maxEntries": 5, "maxChars": 4000 }
194+
195+
https://github.com/rolandmarg/lorebook`);
196+
}

0 commit comments

Comments
 (0)