feat: migrated packages to ts
This commit is contained in:
44
packages/operator/runner.ts
Normal file
44
packages/operator/runner.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user