Skip to content

Commit df1b35e

Browse files
committed
Simplify URL detection: only check first arg after 'index'
Remove argument reordering logic. URL must now appear immediately after 'index', consistent with how other subcommands work: ctxc index https://github.com/owner/repo -i name ✓ ctxc index -i name https://github.com/owner/repo ✗ (error) This is more predictable and matches CLI conventions.
1 parent ad138f4 commit df1b35e

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

src/bin/index.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,13 @@ program.addCommand(mcpCommand);
3030
program.addCommand(agentCommand);
3131

3232
// Auto-detect URL mode: ctxc index <url> -> ctxc index url <url>
33-
// Scan for URL anywhere after 'index' to support: ctxc index -i name https://...
33+
// URL must be the first argument after 'index' (like any subcommand)
3434
const indexIdx = process.argv.indexOf("index");
35-
if (indexIdx !== -1) {
36-
const subcommands = ["url", "github", "gitlab", "bitbucket", "website"];
37-
// Find first URL-like argument after 'index'
38-
for (let i = indexIdx + 1; i < process.argv.length; i++) {
39-
const arg = process.argv[i];
40-
// Stop if we hit a known subcommand
41-
if (subcommands.includes(arg)) break;
42-
// Found a URL - reorder args to put 'url' and the URL right after 'index'
43-
if (arg.match(/^https?:\/\//)) {
44-
// Remove the URL from its current position
45-
process.argv.splice(i, 1);
46-
// Insert 'url' <url> right after 'index'
47-
process.argv.splice(indexIdx + 1, 0, "url", arg);
48-
break;
49-
}
35+
if (indexIdx !== -1 && indexIdx + 1 < process.argv.length) {
36+
const nextArg = process.argv[indexIdx + 1];
37+
if (nextArg.match(/^https?:\/\//)) {
38+
// Insert 'url' before the URL
39+
process.argv.splice(indexIdx + 1, 0, "url");
5040
}
5141
}
5242

0 commit comments

Comments
 (0)