Documentation
¶
Index ¶
- func MustValidateDocumentJSON(document []byte)
- func MustValidateDocumentYAML(document []byte)
- func ValidateDocumentJSON(document []byte) error
- func ValidateDocumentYAML(document []byte) error
- func Versions() []string
- type AlternativeSource
- type Argument
- type Choice
- type Command
- func (cmd Command) BadUserInputErrorCode() int
- func (cmd Command) CanceledErrorCode() int
- func (cmd Command) FixedEnumeratedArgs() bool
- func (cmd Command) FixedEnumeratedFlags() bool
- func (cmd Command) InternalCliErrorCode() int
- func (cmd Command) NotImplementedCode() int
- func (cmd Command) UnauthenticatedErrorCode() int
- func (cmd Command) UnauthorizedErrorCode() int
- func (cmd Command) VariadicEnumeratedArgs() bool
- func (cmd Command) VariadicEnumeratedFlags() bool
- func (cmd Command) VisibleFlags() bool
- type CommandTrie
- type CommandTrieNode
- type ConfigFile
- type Contact
- type DefaultValue
- type Document
- func (d Document) AltSourcesEnv() bool
- func (d Document) AltSourcesJSON() bool
- func (d Document) AltSourcesTOML() bool
- func (d Document) AltSourcesYAML() bool
- func (d Document) Arguments() bool
- func (d Document) BadUserInputErrorCode() int
- func (d Document) FixedEnumeratedArgs() bool
- func (d Document) FixedEnumeratedFlags() bool
- func (d Document) Flags() bool
- func (d Document) InternalCliErrorCode() int
- func (d Document) VariadicEnumeratedArgs() bool
- func (d Document) VariadicEnumeratedFlags() bool
- func (d Document) VisibleFlags() bool
- type ExitCode
- type FileSource
- type Flag
- type Global
- type Info
- type Install
- type License
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustValidateDocumentJSON ¶
func MustValidateDocumentJSON(document []byte)
MustValidateDocumentJSON is a wrapper of ValidateDocumentJSON that panics if the document is invalid.
func MustValidateDocumentYAML ¶
func MustValidateDocumentYAML(document []byte)
MustValidateDocumentYAML is a wrapper of ValidateDocumentYAML that panics if the document is invalid.
func ValidateDocumentJSON ¶
ValidateDocumentJSON validates the given JSON document against the OpenCLI Specification. Any validation errors are returned. If no error is returned, the document is valid.
func ValidateDocumentYAML ¶
ValidateDocumentYAML validates the given YAML document against the OpenCLI Specification. Any validation errors are returned. If no error is returned, the document is valid.
Types ¶
type AlternativeSource ¶
type AlternativeSource struct {
Type string
EnvironmentVariable string
File FileSource
}
type Argument ¶
type Argument struct {
Name string
Summary string
Description string
Type string
Variadic bool
Choices []Choice
Required bool
Default DefaultValue
}
Argument represents an OpenCLI command argument.
type Command ¶
type Command struct {
Line string // The full command line as defined in the OpenCLI Spec Document
Name string // The command part of the command line
LeafName string // The final command in the command line
Params string // The args/flags part of the command line
Aliases []string
Summary string
Description string
Arguments []Argument
Flags []Flag
Hidden bool
Group bool
CmdSpecificExitCodes []ExitCode
ExitCodes []ExitCode
}
Command represents n OpenCLI command.
func (Command) BadUserInputErrorCode ¶
func (Command) CanceledErrorCode ¶
func (Command) FixedEnumeratedArgs ¶
EnumeratedArgs returns true if any fixed arguments on the command contain enumerated values.
func (Command) FixedEnumeratedFlags ¶
EnumeratedFlags returns true if any fixed type flags on the command contain enumerated values.
func (Command) InternalCliErrorCode ¶
func (Command) NotImplementedCode ¶
func (Command) UnauthenticatedErrorCode ¶
func (Command) UnauthorizedErrorCode ¶
func (Command) VariadicEnumeratedArgs ¶
EnumeratedArgs returns true if any variadic arguments on the command contain enumerated values.
func (Command) VariadicEnumeratedFlags ¶
EnumeratedFlags returns true if any variadic type flags on the command contain enumerated values.
func (Command) VisibleFlags ¶
NonHiddenFlags returns true if there are any flags for the given command where Hidden isfalse.
type CommandTrie ¶
type CommandTrie struct {
Root *CommandTrieNode
// contains filtered or unexported fields
}
CommandTrie is a data structure similar to a [Trie](https://en.wikipedia.org/wiki/Trie). Instead of each node containing letters in a string, it contains a command in the command line. This allows us to ensure that grouping commands that may not otherwise be defined in the OpenCLI Doc are accounted for. Grouping commands are commands that are not executable and exist only as an internal node in the trie (not a leaf).
type CommandTrieNode ¶
type CommandTrieNode struct {
Name string
Command Command
Commands []*CommandTrieNode
}
CommandTrieNode represents a hierarchical view of the CLI command structure.
type ConfigFile ¶
type Contact ¶
Contact represents contact information for maintainers of the CLI described by the OpenCLI document.
type DefaultValue ¶
type Document ¶
type Document struct {
OpenCLIVersion string
Info Info
Install []Install
Global Global
CommandTrie *CommandTrie
}
Document represents the OpenCLI document.
func UnmarshalJSON ¶
UnmarshalJSON ummarshalls the given JSON file into an Document domain object.
func UnmarshalYAML ¶
UnmarshalYAML ummarshalls the given YAML file into an Document domain object.
func (Document) AltSourcesEnv ¶
func (Document) AltSourcesJSON ¶
func (Document) AltSourcesTOML ¶
func (Document) AltSourcesYAML ¶
func (Document) BadUserInputErrorCode ¶
func (Document) FixedEnumeratedArgs ¶
EnumeratedArgs returns true if any fixed arguments on any commands contain enumerated values.
func (Document) FixedEnumeratedFlags ¶
EnumeratedFlags returns true if any fixed type flags on any commands contain enumerated values.
func (Document) InternalCliErrorCode ¶
func (Document) VariadicEnumeratedArgs ¶
EnumeratedArgs returns true if any variadic arguments on any commands contain enumerated values.
func (Document) VariadicEnumeratedFlags ¶
EnumeratedFlags returns true if any variadic type flags on any commands contain enumerated values.
func (Document) VisibleFlags ¶
VisibleFlags returns true if any of the commands have visible flags.
type Flag ¶
type Flag struct {
Name string
Aliases []string
Hint string
Summary string
Description string
Type string
Variadic bool
Choices []Choice
Hidden bool
Required bool
Default DefaultValue
AltSources []AlternativeSource
}
Flag represents an OpenCLI command flag.
type Global ¶
type Global struct {
ExitCodes []ExitCode
Flags []Flag
ConfigFiles map[string]ConfigFile
}
Global contains information that applies to the CLI regardless of command context.
type Info ¶
type Info struct {
Title string
Summary string
Description string
License License
Contact Contact
Binary string
Version string
}
Info represents the metadata about the CLI described by the OpenCLI document.