Files
lifeforge/scripts/forge/cli/setup.ts
Melvin Chia cbeaaaa0ea feat(scripts): implement dev command for forge CLI and restructure the entire script
Former-commit-id: 7a1b170002b3b720bade5f247589dc0df15dc538 [formerly dfcab2d757d647b01d710e950d5dbfcdd0b3c1b5] [formerly 606b96d2c5d5c63a7cc1182bd33e389695b30b18 [formerly e1a0ea2bfc43c5fe25deef4f0981573c19b755cd]]
Former-commit-id: c6374c7614ab9ce90306e69b183ccc5afb53f56c [formerly 7cad287e8f8d3ccfb3c9112594865d0e2a0b58d3]
Former-commit-id: 54e9bcf1d0be858779c1cd24806789e0c17e7b0e
2025-10-07 17:24:56 +08:00

63 lines
1.5 KiB
TypeScript

import { program } from 'commander'
import { devHandler, getAvailableServices } from '../commands/dev-commands'
import {
createCommandHandler,
getAvailableCommands
} from '../commands/project-commands'
import { PROJECTS_ALLOWED } from '../constants/constants'
/**
* Sets up the CLI program with all commands
*/
export function setupCLI(): void {
program
.name('Lifeforge Forge')
.description('Build and manage Lifeforge projects')
.version('25w41')
setupProjectCommands()
setupDevCommand()
}
/**
* Sets up project commands (build, types, lint)
*/
function setupProjectCommands(): void {
const availableCommands = getAvailableCommands()
for (const commandType of availableCommands) {
program
.command(commandType)
.description(`Run ${commandType} for specified projects`)
.argument(
'<projects...>',
`Project names to run ${commandType} on. Use 'all' for all projects. Available: all, ${Object.keys(PROJECTS_ALLOWED).join(', ')}`
)
.action(createCommandHandler(commandType))
}
}
/**
* Sets up the dev command
*/
function setupDevCommand(): void {
const availableServices = getAvailableServices()
program
.command('dev')
.description('Start Lifeforge services for development')
.argument(
'<service>',
`Service to start. Use all for starting db, server, and client. Available: ${availableServices.join(', ')}`
)
.action(devHandler)
}
/**
* Parses command line arguments and runs the CLI
*/
export function runCLI(): void {
program.parse()
}