@@ -5,8 +5,29 @@ import { $, argv, chalk, fs, glob, path } from 'zx'
5
5
import { select } from '@inquirer/prompts'
6
6
import { readPackageJSON } from 'pkg-types'
7
7
8
- if ( argv . _ [ 0 ] !== 'sg' ) {
9
- console . log ( chalk . red ( 'Do you want to use `sg` cmd?' ) )
8
+ function printHelp ( ) {
9
+ console . log ( `
10
+ Rewriting at Vue Macros using ast-grep.
11
+
12
+ ${ chalk . underline ( 'Usage:' ) } vue-macros <command> [directory] {(default current directory)}
13
+
14
+ ${ chalk . underline ( 'Commands:' ) }
15
+ sg Rewrite code in specified directory
16
+
17
+ ${ chalk . underline ( 'Options:' ) }
18
+ -h, --help Print help (see more with '--help')
19
+ -V, --version Print version
20
+ ` )
21
+ }
22
+ if ( argv . _ [ 0 ] !== 'sg' || argv . help || argv . h ) {
23
+ printHelp ( )
24
+ process . exit ( )
25
+ }
26
+
27
+ const dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
28
+ if ( argv . v || argv . version ) {
29
+ const localPackageJson = await readPackageJSON ( dirname )
30
+ console . log ( `${ localPackageJson . name } ${ localPackageJson . version } ` )
10
31
process . exit ( )
11
32
}
12
33
@@ -50,12 +71,6 @@ if (macro === 'short-v-model') {
50
71
} )
51
72
}
52
73
53
- const dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
54
- if ( argv . v || argv . version ) {
55
- const localPackageJson = await readPackageJSON ( dirname )
56
- console . log ( `${ localPackageJson . name } ${ localPackageJson . version } ` )
57
- }
58
-
59
74
const target = path . resolve ( argv . _ . at ( 1 ) || './src' )
60
75
async function toSetupSFC ( ) {
61
76
const extname = path . extname ( target )
0 commit comments