-
Notifications
You must be signed in to change notification settings - Fork 37
cli: codedb --help shows "unknown command" instead of usage #150
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Problem
codedb --help outputs unknown command: --help instead of showing the usage text. codedb -h works correctly.
$ codedb --help
✓ indexed 15.6ms
✗ unknown command: --help
$ codedb -h
codedb code intelligence server
usage: codedb [root] <command> [args...]
...
Root Cause
src/main.zig:68 parses --help and sets cmd = "--help", but there is no dispatch for it later. The --version handler at line 89 exists, but no equivalent --help handler was added.
Failing Test
test "issue-150: --help flag prints usage" {
const result = std.process.Child.run(.{
.allocator = testing.allocator,
.argv = &.{ "zig", "build", "run", "--", "--help" },
.max_output_bytes = 4096,
});
defer testing.allocator.free(result.stdout);
defer testing.allocator.free(result.stderr);
// Should exit 0 and contain usage text
try testing.expect(result.term.Exited == 0);
try testing.expect(std.mem.indexOf(u8, result.stdout, "usage:") != null);
}Fix
Add a --help dispatch after the --version handler at line 92 of src/main.zig:
if (std.mem.eql(u8, cmd, "--help") or std.mem.eql(u8, cmd, "-h") or std.mem.eql(u8, cmd, "help")) {
printUsage(out, s);
return;
}Environment
- codedb v0.2.53
- macOS arm64 / Linux x86_64
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working