Files
aklive2d/packages/operator/runner.ts
2025-05-02 02:27:42 +08:00

45 lines
961 B
TypeScript

import { envParser } from '@aklive2d/libs'
import { build, init } from './index.ts'
type Args = {
mode: string
name: string[]
id: string
}
async function main() {
const { mode, name, id } = envParser.parse({
mode: {
type: 'string',
short: 'm',
},
name: {
type: 'string',
short: 'n',
multiple: true,
default: [],
},
id: {
type: 'string',
},
}) as Args
switch (mode) {
case 'build':
await build(name)
break
case 'init':
if (!name.length) {
throw new Error('Please set the operator name.')
}
if (!id) {
throw new Error('Please set the operator id.')
}
init(name[0], id)
break
default:
throw new Error(`Unknown mode: ${mode}`)
}
}
main()