Skip to content

Commit ea812f3

Browse files
committed
💥 breaking(cli): change infuse command options
1 parent aaaf986 commit ea812f3

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ vue-i18n-locale-message squeeze --target=./src --output=./messages.json
9898
#### Infuse
9999

100100
```sh
101-
vue-i18n-locale-message infuse --target=./src --messages=./translated.json
101+
vue-i18n-locale-message infuse --target=./src --locales=./translated.json
102102
```
103103

104104
## :raising_hand: Motivations

src/commands/infuse.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const debug = Debug('vue-i18n-locale-message:commands:infuse')
1414

1515
type InfuseOptions = {
1616
target: string
17-
messages: string
17+
locales: string
1818
match?: string
1919
}
2020

@@ -30,22 +30,22 @@ export const builder = (args: Argv): Argv<InfuseOptions> => {
3030
describe: 'target path that single-file components is stored',
3131
demandOption: true
3232
})
33-
.option('messages', {
33+
.option('locales', {
3434
type: 'string',
35-
alias: 'm',
35+
alias: 'l',
3636
describe: 'locale messages path to be infused',
3737
demandOption: true
3838
})
3939
.option('match', {
4040
type: 'string',
41-
alias: 'r',
41+
alias: 'm',
4242
describe: 'option should be accepted a regex filenames, must be specified together --messages'
4343
})
4444
}
4545

4646
export const handler = (args: Arguments<InfuseOptions>): void => {
4747
const targetPath = resolve(args.target)
48-
const messagesPath = resolve(args.messages)
48+
const messagesPath = resolve(args.locales)
4949
const sources = readSFC(targetPath)
5050
const messages = readLocaleMessages(messagesPath, args.match)
5151
const meta = squeeze(targetPath, sources)

test/__snapshots__/cli.test.ts.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ exports[`infuse command output help 1`] = `
66
infuse locale messages to single-file components
77
88
Options:
9-
--version Show version number [boolean]
10-
--help Show help [boolean]
11-
--target, -t target path that single-file components is stored
9+
--version Show version number [boolean]
10+
--help Show help [boolean]
11+
--target, -t target path that single-file components is stored
1212
[string] [required]
13-
--messages, -m locale messages path to be infused [string] [required]
14-
--match, -r option should be accepted a regex filenames, must be specified
15-
together --messages [string]"
13+
--locales, -l locale messages path to be infused [string] [required]
14+
--match, -m option should be accepted a regex filenames, must be specified
15+
together --messages [string]"
1616
`;
1717

1818
exports[`squeeze command output help 1`] = `

test/commands/infuse.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ test('absolute path', async () => {
8686
const infuse = await import('../../src/commands/infuse')
8787
const cmd = yargs.command(infuse)
8888
const output = await new Promise(resolve => {
89-
cmd.parse(`infuse --target=${TARGET_PATH}/src --messages=${TARGET_PATH}/locales.json`, () => {
89+
cmd.parse(`infuse --target=${TARGET_PATH}/src --locales=${TARGET_PATH}/locales.json`, () => {
9090
resolve(writeFiles)
9191
})
9292
})
@@ -120,7 +120,7 @@ test('relative path', async () => {
120120
const infuse = await import('../../src/commands/infuse')
121121
const cmd = yargs.command(infuse)
122122
const output = await new Promise(resolve => {
123-
cmd.parse(`infuse --target=./src --messages=locales-2.json`, () => {
123+
cmd.parse(`infuse --target=./src --locales=locales-2.json`, () => {
124124
resolve(writeFiles)
125125
})
126126
})
@@ -154,7 +154,7 @@ test('match option', async () => {
154154
const infuse = await import('../../src/commands/infuse')
155155
const cmd = yargs.command(infuse)
156156
const output = await new Promise(resolve => {
157-
cmd.parse(`infuse --target=./src --messages=./src/locales --match=^([\\w-]*)\\.json`, () => {
157+
cmd.parse(`infuse --target=./src --locales=./src/locales --match=^([\\w-]*)\\.json`, () => {
158158
resolve(writeFiles)
159159
})
160160
})

0 commit comments

Comments
 (0)