1 | #!/usr/bin/env node
|
2 |
|
3 | const cli = require('commander')
|
4 | const pkg = require('./package.json')
|
5 | const cfg = require('./lib/config')
|
6 | const core = require('./core')
|
7 |
|
8 | cli.version(pkg.version).usage('<command> [option] <addon ...>')
|
9 |
|
10 | cli
|
11 | .command('add <addons...>')
|
12 | .description('install one or more addons locally')
|
13 | .alias('install')
|
14 | .option('--anyway', 'install latest addon release for _classic_ mode anyway')
|
15 | .action((aa, cmd) => {
|
16 | cfg.anyway(cmd.anyway)
|
17 | core.add(aa)
|
18 | })
|
19 |
|
20 | cli
|
21 | .command('rm <addon>')
|
22 | .description('remove an addon from local installation')
|
23 | .alias('delete')
|
24 | .action(key => core.rm(key))
|
25 |
|
26 | cli
|
27 | .command('search <text>')
|
28 | .description('search addons whose name contain <text>')
|
29 | .option(
|
30 | '--anyway',
|
31 | 'search for latest addon release for _classic_ mode anyway'
|
32 | )
|
33 | .action((text, cmd) => {
|
34 | cfg.anyway(cmd.anyway)
|
35 | core.search(text)
|
36 | })
|
37 |
|
38 | cli
|
39 | .command('ls')
|
40 | .description('list all installed addons')
|
41 | .alias('list')
|
42 | .action(core.ls)
|
43 |
|
44 | cli
|
45 | .command('info <addon>')
|
46 | .description(
|
47 | 'show info of an addon, the addon does not have to be an installed locally'
|
48 | )
|
49 | .option(
|
50 | '--anyway',
|
51 | 'show info of latest addon release for _classic_ mode anyway'
|
52 | )
|
53 | .action((ad, cmd) => {
|
54 | cfg.anyway(cmd.anyway)
|
55 | core.info(ad)
|
56 | })
|
57 |
|
58 | cli
|
59 | .command('update')
|
60 | .description('update all installed addons')
|
61 | .option('--anyway', 'update latest addon release for _classic_ mode anyway')
|
62 | .action(cmd => {
|
63 | cfg.anyway(cmd.anyway)
|
64 | core.update()
|
65 | })
|
66 |
|
67 | cli
|
68 | .command('import')
|
69 | .description('import local addons')
|
70 | .action(() => core.pickup())
|
71 |
|
72 | cli
|
73 | .command('switch')
|
74 | .alias('sw')
|
75 | .description('switch mode between retail and classic')
|
76 | .action(core.switch)
|
77 |
|
78 | cli
|
79 | .command('restore [repo]')
|
80 | .description(
|
81 | 'restore addons from github repo, only <org/repo> is required, not the full URL. (e.g. antiwinter/wowui)'
|
82 | )
|
83 | .option(
|
84 | '-f, --full',
|
85 | 'not only restore addons, but also restore addons settings'
|
86 | )
|
87 | .action(repo => core.restore(repo))
|
88 |
|
89 | cli.on('command:*', () => {
|
90 | cli.help()
|
91 | })
|
92 |
|
93 | if (process.argv.length < 3) return cli.help()
|
94 |
|
95 |
|
96 | core.checkUpdate(() => {
|
97 | core.updateSummary(() => {
|
98 | cli.parse(process.argv)
|
99 | })
|
100 | })
|