Skip to content

Commit 655a971

Browse files
committed
Allow direct URL syntax: ctxc index <url> without 'url' subcommand
Adds pre-parse argument rewriting that auto-detects when a URL is passed directly to 'ctxc index' and transparently inserts the 'url' subcommand. Before: ctxc index url https://github.com/owner/repo After: ctxc index https://github.com/owner/repo Both syntaxes now work. Existing subcommands (github, gitlab, etc.) are unchanged and continue to work. Agent-Id: agent-ce81a04d-72f2-4289-8eb7-c3074d7d8030
1 parent bef6eb7 commit 655a971

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/bin/index.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,18 @@ program.addCommand(searchCommand);
2929
program.addCommand(mcpCommand);
3030
program.addCommand(agentCommand);
3131

32-
program.parse();
32+
// Auto-detect URL mode: ctxc index <url> -> ctxc index url <url>
33+
// This allows users to skip the 'url' subcommand when providing a URL directly
34+
const indexIdx = process.argv.indexOf("index");
35+
if (indexIdx !== -1 && indexIdx + 1 < process.argv.length) {
36+
const nextArg = process.argv[indexIdx + 1];
37+
const subcommands = ["url", "github", "gitlab", "bitbucket", "website"];
38+
if (
39+
nextArg.match(/^https?:\/\//) &&
40+
!subcommands.includes(nextArg)
41+
) {
42+
process.argv.splice(indexIdx + 1, 0, "url");
43+
}
44+
}
3345

46+
program.parse();

0 commit comments

Comments
 (0)