@@ -28,108 +28,109 @@ type contextKey string
28
28
// Command may contain Flags and sub-commands in Commands.
29
29
type Command struct {
30
30
// The name of the command
31
- Name string
31
+ Name string `json:"name"`
32
32
// A list of aliases for the command
33
- Aliases []string
33
+ Aliases []string `json:"aliases"`
34
34
// A short description of the usage of this command
35
- Usage string
35
+ Usage string `json:"usage"`
36
36
// Text to override the USAGE section of help
37
- UsageText string
37
+ UsageText string `json:"usageText"`
38
38
// A short description of the arguments of this command
39
- ArgsUsage string
39
+ ArgsUsage string `json:"argsUsage"`
40
40
// Version of the command
41
- Version string
41
+ Version string `json:"version"`
42
42
// Longer explanation of how the command works
43
- Description string
43
+ Description string `json:"description"`
44
44
// DefaultCommand is the (optional) name of a command
45
45
// to run if no command names are passed as CLI arguments.
46
- DefaultCommand string
46
+ DefaultCommand string `json:"defaultCommand"`
47
47
// The category the command is part of
48
- Category string
48
+ Category string `json:"category"`
49
49
// List of child commands
50
- Commands []* Command
50
+ Commands []* Command `json:"commands"`
51
51
// List of flags to parse
52
- Flags []Flag
52
+ Flags []Flag `json:"flags"`
53
53
// Boolean to hide built-in help command and help flag
54
- HideHelp bool
54
+ HideHelp bool `json:"hideHelp"`
55
55
// Ignored if HideHelp is true.
56
- HideHelpCommand bool
56
+ HideHelpCommand bool `json:"hideHelpCommand"`
57
57
// Boolean to hide built-in version flag and the VERSION section of help
58
- HideVersion bool
58
+ HideVersion bool `json:"hideVersion"`
59
59
// Boolean to enable shell completion commands
60
- EnableShellCompletion bool
60
+ EnableShellCompletion bool `json:"-"`
61
61
// Shell Completion generation command name
62
- ShellCompletionCommandName string
62
+ ShellCompletionCommandName string `json:"-"`
63
63
// The function to call when checking for shell command completions
64
- ShellComplete ShellCompleteFunc
64
+ ShellComplete ShellCompleteFunc `json:"-"`
65
65
// An action to execute before any subcommands are run, but after the context is ready
66
66
// If a non-nil error is returned, no subcommands are run
67
- Before BeforeFunc
67
+ Before BeforeFunc `json:"-"`
68
68
// An action to execute after any subcommands are run, but after the subcommand has finished
69
69
// It is run even if Action() panics
70
- After AfterFunc
70
+ After AfterFunc `json:"-"`
71
71
// The function to call when this command is invoked
72
- Action ActionFunc
72
+ Action ActionFunc `json:"-"`
73
73
// Execute this function if the proper command cannot be found
74
- CommandNotFound CommandNotFoundFunc
74
+ CommandNotFound CommandNotFoundFunc `json:"-"`
75
75
// Execute this function if a usage error occurs.
76
- OnUsageError OnUsageErrorFunc
76
+ OnUsageError OnUsageErrorFunc `json:"-"`
77
77
// Execute this function when an invalid flag is accessed from the context
78
- InvalidFlagAccessHandler InvalidFlagAccessFunc
78
+ InvalidFlagAccessHandler InvalidFlagAccessFunc `json:"-"`
79
79
// Boolean to hide this command from help or completion
80
- Hidden bool
80
+ Hidden bool `json:"hidden"`
81
81
// List of all authors who contributed (string or fmt.Stringer)
82
- Authors []any // TODO: ~string | fmt.Stringer when interface unions are available
82
+ // TODO: ~string | fmt.Stringer when interface unions are available
83
+ Authors []any `json:"authors"`
83
84
// Copyright of the binary if any
84
- Copyright string
85
+ Copyright string `json:"copyright"`
85
86
// Reader reader to write input to (useful for tests)
86
- Reader io.Reader
87
+ Reader io.Reader `json:"-"`
87
88
// Writer writer to write output to
88
- Writer io.Writer
89
+ Writer io.Writer `json:"-"`
89
90
// ErrWriter writes error output
90
- ErrWriter io.Writer
91
+ ErrWriter io.Writer `json:"-"`
91
92
// ExitErrHandler processes any error encountered while running an App before
92
93
// it is returned to the caller. If no function is provided, HandleExitCoder
93
94
// is used as the default behavior.
94
- ExitErrHandler ExitErrHandlerFunc
95
+ ExitErrHandler ExitErrHandlerFunc `json:"-"`
95
96
// Other custom info
96
- Metadata map [string ]interface {}
97
+ Metadata map [string ]interface {} `json:"metadata"`
97
98
// Carries a function which returns app specific info.
98
- ExtraInfo func () map [string ]string
99
+ ExtraInfo func () map [string ]string `json:"-"`
99
100
// CustomRootCommandHelpTemplate the text template for app help topic.
100
101
// cli.go uses text/template to render templates. You can
101
102
// render custom help text by setting this variable.
102
- CustomRootCommandHelpTemplate string
103
+ CustomRootCommandHelpTemplate string `json:"-"`
103
104
// SliceFlagSeparator is used to customize the separator for SliceFlag, the default is ","
104
- SliceFlagSeparator string
105
+ SliceFlagSeparator string `json:"sliceFlagSeparator"`
105
106
// DisableSliceFlagSeparator is used to disable SliceFlagSeparator, the default is false
106
- DisableSliceFlagSeparator bool
107
+ DisableSliceFlagSeparator bool `json:"disableSliceFlagSeparator"`
107
108
// Boolean to enable short-option handling so user can combine several
108
109
// single-character bool arguments into one
109
110
// i.e. foobar -o -v -> foobar -ov
110
- UseShortOptionHandling bool
111
+ UseShortOptionHandling bool `json:"useShortOptionHandling"`
111
112
// Enable suggestions for commands and flags
112
- Suggest bool
113
+ Suggest bool `json:"suggest"`
113
114
// Allows global flags set by libraries which use flag.XXXVar(...) directly
114
115
// to be parsed through this library
115
- AllowExtFlags bool
116
+ AllowExtFlags bool `json:"allowExtFlags"`
116
117
// Treat all flags as normal arguments if true
117
- SkipFlagParsing bool
118
+ SkipFlagParsing bool `json:"skipFlagParsing"`
118
119
// CustomHelpTemplate the text template for the command help topic.
119
120
// cli.go uses text/template to render templates. You can
120
121
// render custom help text by setting this variable.
121
- CustomHelpTemplate string
122
+ CustomHelpTemplate string `json:"-"`
122
123
// Use longest prefix match for commands
123
- PrefixMatchCommands bool
124
+ PrefixMatchCommands bool `json:"prefixMatchCommands"`
124
125
// Custom suggest command for matching
125
- SuggestCommandFunc SuggestCommandFunc
126
+ SuggestCommandFunc SuggestCommandFunc `json:"-"`
126
127
// Flag exclusion group
127
- MutuallyExclusiveFlags []MutuallyExclusiveFlags
128
+ MutuallyExclusiveFlags []MutuallyExclusiveFlags `json:"mutuallyExclusiveFlags"`
128
129
// Arguments to parse for this command
129
- Arguments []Argument
130
+ Arguments []Argument `json:"arguments"`
130
131
// Whether to read arguments from stdin
131
132
// applicable to root command only
132
- ReadArgsFromStdin bool
133
+ ReadArgsFromStdin bool `json:"readArgsFromStdin"`
133
134
134
135
// categories contains the categorized commands and is populated on app startup
135
136
categories CommandCategories
0 commit comments