You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add old "passthrough" behaviour back in as an option
`passthrough:""` or `passthrough:"all"` (the default) will pass through
all further arguments including unrecognised flags.
`passthrough:"partial"` will validate flags up until the `--` or the
first positional argument, then pass through all subsequent flags and
arguments.
Copy file name to clipboardExpand all lines: README.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -590,9 +590,13 @@ Both can coexist with standard Tag parsing.
590
590
|`envprefix:"X"`| Envar prefix for all sub-flags. |
591
591
|`set:"K=V"`| Set a variable for expansion by child elements. Multiples can occur. |
592
592
|`embed:""`| If present, this field's children will be embedded in the parent. Useful for composition. |
593
-
|`passthrough:""`| If present on a positional argument, it stops flag parsing when encountered, as if `--` was processed before. Useful for external command wrappers, like `exec`. On a command it requires that the command contains only one argument of type `[]string` which is then filled with everything following the command, unparsed. |
593
+
|`passthrough:"<mode>"`[^1]| If present on a positional argument, it stops flag parsing when encountered, as if `--` was processed before. Useful for external command wrappers, like `exec`. On a command it requires that the command contains only one argument of type `[]string` which is then filled with everything following the command, unparsed. |
594
594
|`-`| Ignore the field. Useful for adding non-CLI fields to a configuration struct. e.g `` `kong:"-"` ``|
595
595
596
+
[^1]: `<mode>` can be `partial` or `all` (the default). `all` will pass through all arguments including flags, including
597
+
flags. `partial` will validate flags until the first positional argument is encountered, then pass through all remaining
598
+
positional arguments.
599
+
596
600
## Plugins
597
601
598
602
Kong CLI's can be extended by embedding the `kong.Plugin` type and populating it with pointers to Kong annotated structs. For example:
Copy file name to clipboardExpand all lines: tag.go
+51-29Lines changed: 51 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -9,37 +9,50 @@ import (
9
9
"unicode/utf8"
10
10
)
11
11
12
+
// PassthroughMode indicates how parameters are passed through when "passthrough" is set.
13
+
typePassthroughModeint
14
+
15
+
const (
16
+
// PassThroughModeNone indicates passthrough mode is disabled.
17
+
PassThroughModeNonePassthroughMode=iota
18
+
// PassThroughModeAll indicates that all parameters, including flags, are passed through. It is the default.
19
+
PassThroughModeAll
20
+
// PassThroughModePartial will validate flags until the first positional argument is encountered, then pass through all remaining positional arguments.
21
+
PassThroughModePartial
22
+
)
23
+
12
24
// Tag represents the parsed state of Kong tags in a struct field tag.
13
25
typeTagstruct {
14
-
Ignoredbool// Field is ignored by Kong. ie. kong:"-"
15
-
Cmdbool
16
-
Argbool
17
-
Requiredbool
18
-
Optionalbool
19
-
Namestring
20
-
Helpstring
21
-
Typestring
22
-
TypeNamestring
23
-
HasDefaultbool
24
-
Defaultstring
25
-
Formatstring
26
-
PlaceHolderstring
27
-
Envs []string
28
-
Shortrune
29
-
Hiddenbool
30
-
Seprune
31
-
MapSeprune
32
-
Enumstring
33
-
Groupstring
34
-
Xor []string
35
-
And []string
36
-
VarsVars
37
-
Prefixstring// Optional prefix on anonymous structs. All sub-flags will have this prefix.
38
-
EnvPrefixstring
39
-
Embedbool
40
-
Aliases []string
41
-
Negatablestring
42
-
Passthroughbool
26
+
Ignoredbool// Field is ignored by Kong. ie. kong:"-"
27
+
Cmdbool
28
+
Argbool
29
+
Requiredbool
30
+
Optionalbool
31
+
Namestring
32
+
Helpstring
33
+
Typestring
34
+
TypeNamestring
35
+
HasDefaultbool
36
+
Defaultstring
37
+
Formatstring
38
+
PlaceHolderstring
39
+
Envs []string
40
+
Shortrune
41
+
Hiddenbool
42
+
Seprune
43
+
MapSeprune
44
+
Enumstring
45
+
Groupstring
46
+
Xor []string
47
+
And []string
48
+
VarsVars
49
+
Prefixstring// Optional prefix on anonymous structs. All sub-flags will have this prefix.
50
+
EnvPrefixstring
51
+
Embedbool
52
+
Aliases []string
53
+
Negatablestring
54
+
Passthroughbool// Deprecated: use PassthroughMode instead.
55
+
PassthroughModePassthroughMode
43
56
44
57
// Storage for all tag keys for arbitrary lookups.
0 commit comments