-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
63 lines (60 loc) · 1.66 KB
/
index.ts
File metadata and controls
63 lines (60 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { initDatabase, indexingCodebase } from '@tool/Indexing'
import { toolCalling } from '@tool/ToolCalling'
/**
* Available commands
* @description Available commands
* @returns void
*/
const availableCommands = [
{ id: 'init', description: 'Initialize the database' },
{ id: 'indexing', description: 'Do indexing codebase' },
{ id: 'tool-calling', description: 'Do tool calling process' },
{ id: 'help', description: 'Show help' }
]
/**
* Shows the help for the available commands
* @description Shows the help for the available commands
* @returns void
*/
const commandHelp = () => {
console.log('Usage: npx tsx ./scripts/index.ts <command>')
console.log('Commands :')
availableCommands.forEach((command) => {
console.log(` ${command.id} - ${command.description}`)
})
process.exit(1)
}
/**
* Parses the command and executes the appropriate function
* @description Parses the command and executes the appropriate function
* @returns void
*/
const commandParsing = async () => {
const args = process.argv.slice(2)
if (args.length === 0) {
return commandHelp()
}
const command = args[0]
if (!availableCommands.some((c) => c.id === command)) {
return commandHelp()
}
switch (command) {
case 'init':
await initDatabase()
console.log('Database initialized')
process.exit(0)
case 'indexing':
await indexingCodebase()
console.log('Indexing codebase completed')
process.exit(0)
case 'tool-calling':
await toolCalling()
console.log('Tool calling completed')
process.exit(0)
case 'help':
return commandHelp()
default:
return commandHelp()
}
}
commandParsing()