import { cac } from 'cac' ; import { version } from '../package.json' ; import { handleError } from './errors' ; import type { CliOptions } from './types' ; import { build } from './index' ; const name = 'unocss' ; async function main ( options = { } ) { const cli = cac ( name ) ; cli . command ( '[...patterns]' , 'Glob patterns' , { ignoreOptionDefaultValue : true , } ) . option ( '-o, --out-file <file>' , 'Output file' , { default : process . cwd ( ) , } ) . option ( '-w, --watch' , 'Watch for file changes' ) . action ( async ( patterns , flags ) => { Object . assign ( options , { ... flags , } ) ; if ( patterns ) options . patterns = patterns ; await build ( options ) ; } ) ; cli . help ( ) ; cli . version ( version ) ; cli . parse ( process . argv , { run : false } ) ; await cli . runMatchedCommand ( ) ; } main ( ) . catch ( handleError ) ;