import { cac } from 'cac' ; import { build } from './index' ; import { name , version } from '../../package.json' ; import { handleError } from './errors' ; import type { CliOptions } from './types' ; async function main ( options = { } ) { const cli = cac ( name ) ; cli . command ( '[file]' , 'Panel input file' , { ignoreOptionDefaultValue : true } ) . option ( '-d, --out-dir <dir>' , 'Output directory' , { default : process . cwd ( ) } ) . option ( '--watch [path]' , 'Watch mode, if path is not specified, it watches the folder of the input file. Repeat "--watch" for multiple paths' ) . action ( async ( file , flags ) => { Object . assign ( options , { ... flags } ) ; if ( file ) { options . entry = file ; } await build ( options ) ; } ) ; cli . help ( ) ; cli . version ( version ) ; cli . parse ( process . argv , { run : false } ) ; await cli . runMatchedCommand ( ) ; } main ( ) . catch ( handleError ) ;