@@ -5,8 +5,29 @@ import { $, argv, chalk, fs, glob, path } from 'zx'
55import { select } from '@inquirer/prompts'
66import { readPackageJSON } from 'pkg-types'
77
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 } ` )
1031 process . exit ( )
1132}
1233
@@ -50,12 +71,6 @@ if (macro === 'short-v-model') {
5071 } )
5172}
5273
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-
5974const target = path . resolve ( argv . _ . at ( 1 ) || './src' )
6075async function toSetupSFC ( ) {
6176 const extname = path . extname ( target )
0 commit comments