-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathdeno_flags.deno.txt
66 lines (55 loc) · 3.42 KB
/
deno_flags.deno.txt
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
┏━━━━━━━━━━━━━━━━┓
┃ DENO_FLAGS ┃
┗━━━━━━━━━━━━━━━━┛
ALTERNATIVES ==> #See yargs
VERSION ==> #See Deno doc
Deno.args #STR_ARR. CLI argv, excluding deno commands|flags
@std/cli/parse-args #
parseArgs(STR_ARR[, OPTS]) #Parse CLI flags
->FLAGS_OBJ #STR_ARR is usually Deno.args
--FLAG
--FLAG=VAR
--FLAG VAR
-F
-F=VAR
-F VAR #Syntax of flags
-ABC... #Can use multiple single character flags in a row
CASE ==> #Case is not converted:
# - keep user-specified case as is
# - only matches user-specified case
FLAGS._ #STR|NUM_ARR. Non-flags arguments (neither key|value)
OPTS.stopEarly #BOOL (def: false).
#On the first non-flag argument, consider all following arguments as non-flag
#E.g. ['a', '-b']:
# - false: { _: ['a'], b: true }
# - true: { _: ['a', '-b'] }
OPTS.-- #BOOL (def: false). Split FLAGs._ into:
# - FLAGS._: before --
# - FLAGS.--: after --
#In both cases, -- itself is not returned
OPTS.unknown #FUNC('RAW_ARG'[, 'FLAG', VAL])->BOOL
#If returning false (def: true), ignore argument
#Called on:
# - not a flag
# - FLAG|VAL are undefined then
# - flag not defined in OPTS.boolean|string|alias
OPTS.boolean #BOOL or 'FLAG'[_ARR] with type BOOL:
# - value transtyped to BOOL (including 'true|false')
# - default value false
#If true, treats all flags as BOOL, except --FLAG=VAL or -F=VAL
#If false (def), same as []
#In any case, flags with no values are considered BOOL
OPTS.negatable #'FLAG'[_ARR] with value false when using --no-*
NUMBER FLAGS ==> #Automatically transtyped
# - except: after --
#Including FLOAT
#Including negative NUM, but only as --FLAG=-NUM or -F=-NUM
OPTS.string #'FLAG'[_ARR] (def: []) with type STR, i.e. no BOOL|NUM conversion
OPTS.collect #'FLAG'[_ARR] with type ARR.
# - flag must be repeated
# - default value []
OBJECT FLAGS ==> #'VARR' automatically converted to OBJ
#NUM keys are considered OBJ keys, not ARR
OPTS.alias.FLAG #'FLAG2'[_ARR] alias name
#FLAGS.* contains both name before|after aliasing
OPTS.default.FLAG #VAL. Default value