forked from marktext/marktext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.js
More file actions
35 lines (30 loc) · 853 Bytes
/
parser.js
File metadata and controls
35 lines (30 loc) · 853 Bytes
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
import arg from 'arg'
/**
* Parse the given arguments or the default program arguments.
*
* @param {string[]} argv Arguments if null the default program arguments are used.
* @param {boolean} permissive If set to false an exception is throw about unknown flags.
* @returns {arg.Result} Parsed arguments
*/
const parseArgs = (argv = null, permissive = true) => {
if (argv === null) {
argv = process.argv.slice(1)
}
const spec = {
'--debug': Boolean,
'--safe': Boolean,
'--new-window': Boolean,
'-n': '--new-window',
'--disable-gpu': Boolean,
'--disable-spellcheck': Boolean,
'--user-data-dir': String,
// Misc
'--help': Boolean,
'-h': '--help',
'--verbose': arg.COUNT,
'-v': '--verbose',
'--version': Boolean
}
return arg(spec, { argv, permissive })
}
export default parseArgs