@@ -2,8 +2,7 @@ import process from 'node:process'
2
2
3
3
import * as p from '@clack/prompts'
4
4
import c from 'ansis'
5
- import yargs from 'yargs'
6
- import { hideBin } from 'yargs/helpers'
5
+ import { cac } from 'cac'
7
6
8
7
import { pkgJson } from './constants'
9
8
import { run } from './run'
@@ -13,48 +12,25 @@ function header(): void {
13
12
p . intro ( `${ c . green `@antfu/eslint-config ` } ${ c . dim `v${ pkgJson . version } ` } ` )
14
13
}
15
14
16
- const instance = yargs ( hideBin ( process . argv ) )
17
- . scriptName ( '@antfu/eslint-config' )
18
- . usage ( '' )
19
- . command (
20
- '*' ,
21
- 'Run the initialization or migration' ,
22
- args => args
23
- . option ( 'yes' , {
24
- alias : 'y' ,
25
- description : 'Skip prompts and use default values' ,
26
- type : 'boolean' ,
27
- } )
28
- . option ( 'template' , {
29
- alias : 't' ,
30
- description : 'Use the framework template for optimal customization: vue / react / svelte / astro' ,
31
- type : 'string' ,
32
- } )
33
- . option ( 'extra' , {
34
- alias : 'e' ,
35
- array : true ,
36
- description : 'Use the extra utils: formatter / perfectionist / unocss' ,
37
- type : 'string' ,
38
- } )
39
- . help ( ) ,
40
- async ( args ) => {
41
- header ( )
42
- try {
43
- await run ( args )
44
- }
45
- catch ( error ) {
46
- p . log . error ( c . inverse . red ( ' Failed to migrate ' ) )
47
- p . log . error ( c . red `✘ ${ String ( error ) } ` )
48
- process . exit ( 1 )
49
- }
50
- } ,
51
- )
52
- . showHelpOnFail ( false )
53
- . alias ( 'h' , 'help' )
54
- . version ( 'version' , pkgJson . version )
55
- . alias ( 'v' , 'version' )
15
+ const cli = cac ( '@antfu/eslint-config' )
56
16
57
- // eslint-disable-next-line ts/no-unused-expressions
58
- instance
59
- . help ( )
60
- . argv
17
+ cli
18
+ . command ( '' , 'Run the initialization or migration' )
19
+ . option ( '--yes, -y' , 'Skip prompts and use default values' , { default : false } )
20
+ . option ( '--template, -t <template>' , 'Use the framework template for optimal customization: vue / react / svelte / astro' , { type : [ ] } )
21
+ . option ( '--extra, -e <extra>' , 'Use the extra utils: formatter / perfectionist / unocss' , { type : [ ] } )
22
+ . action ( async ( args ) => {
23
+ header ( )
24
+ try {
25
+ await run ( args )
26
+ }
27
+ catch ( error ) {
28
+ p . log . error ( c . inverse . red ( ' Failed to migrate ' ) )
29
+ p . log . error ( c . red `✘ ${ String ( error ) } ` )
30
+ process . exit ( 1 )
31
+ }
32
+ } )
33
+
34
+ cli . help ( )
35
+ cli . version ( pkgJson . version )
36
+ cli . parse ( )
0 commit comments