-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·70 lines (66 loc) · 1.62 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env node
var meow = require('meow')
var help = 'Usage:\n' +
' $ drs-extract --create /path/to/archive.drs\n' +
' $ drs-extract /path/to/archive.drs [--extract|--get|--add|--list] [options]\n' +
'\n' +
'Examples:\n' +
' Extract all files from an archive to a folder:\n' +
' $ drs-extract /path/to/archive.drs --extract /path/to/output/folder/\n' +
'\n' +
' Print the contents of a single file to stdout:\n' +
' $ drs-extract /path/to/archive.drs --get 51000\n' +
'\n' +
' Add a file to an archive:\n' +
' $ drs-extract /path/to/archive.drs --table bina --add 51000 /path/to/palette.pal\n' +
' $ generate-file | drs-extract /path/to/archive.drs --table bina --add 32533\n' +
'\n' +
' Print a list of files in the archive:\n' +
' $ drs-extract /path/to/archive.drs --list\n'
var cli = meow(help, {
flags: {
create: {
type: 'string',
alias: 'c'
},
extract: {
type: 'boolean',
alias: 'e'
},
get: {
type: 'boolean',
alias: 'g'
},
add: {
type: 'string',
alias: 'a'
},
list: {
type: 'boolean',
alias: 'l'
},
table: {
type: 'string',
alias: 't'
},
}
})
var command
if (cli.flags.create) {
command = require('./lib/create')
} else if (cli.flags.extract) {
command = require('./lib/extract')
} else if (cli.flags.get) {
command = require('./lib/get')
} else if (cli.flags.add) {
command = require('./lib/add')
} else if (cli.flags.list) {
command = require('./lib/list')
}
if (command) {
command(cli, function (err) {
if (err) throw err
})
} else {
cli.showHelp()
}