Validation note
This JSON Schema helps enforce structural validity, but not every validation rule can be represented in JSON Schema alone.
For full spec validation, run the OpenCLI CLI check command.
Version
The current version of the OpenCLI Specification is 1.0.0-alpha.9.
OpenCLI Specification
This is the root object of an OpenCLI Specification-compliant document.
Fields
| Field Name | Type | Description |
|---|---|---|
opencliVersion | stringrequired | This property MUST be the exact version number of the OpenCLI Specification that this OpenCLI Document uses. The opencli field SHOULD be used by tooling to interpret the OpenCLI Document. This field is not related to the CLI
|
info | InfoObjectrequired | Provides metadata about the CLI. This metadata is used for generating help output and documentation. |
install | [InstallMethodItemObject] | The installation methods available for the CLI. |
global | GlobalObject | properties that apply to all commands |
commands | Map<string, CommandItemObject> | The commands available for the CLI. Each key should contain the full command starting with the CLI binary name (e.g.: |
InfoObject
Provides metadata about the CLI. This metadata is used for generating help output and documentation.
Fields
| Field Name | Type | Description |
|---|---|---|
title | stringrequired | The title of the CLI. This will appear in generated help output and documentation. |
summary | string | A short summary of the CLI. This will appear in generated help output and documentation in addition to the description. Markdown may be used for rich text representation. |
description | string | A longer description of the CLI. This will appear in generated help output and documentation in addition to the summary. Markdown may be used for rich text representation. |
license | LicenseObject | Describes the license used by the CLI. |
contact | ContactObject | Contact information for the CLI. |
binary | stringrequired | The name of the CLI binary. This is the name that will be used to invoke the CLI from the command line. |
version | stringrequired | The version of the OpenCLI Document which typically corresponds to the release version of your CLI. |
LicenseObject
Describes the license used by the CLI.
Fields
| Field Name | Type | Description |
|---|---|---|
name | stringrequired | The name of the license used by the CLI. |
spdxId | string | The SPDX identifier of the license used by the CLI. |
url | string | A URL to the license used by the CLI. |
ContactObject
Contact information for the CLI.
Fields
| Field Name | Type | Description |
|---|---|---|
name | stringconditional | The name of the contact person/organization. |
email | stringconditional | The email address of the contact person/organization. |
url | stringconditional | A URL pointing to the contact information. |
InstallMethodItemObject
An installation method for the CLI.
Fields
| Field Name | Type | Description |
|---|---|---|
name | stringrequired | The name of the installation method. |
command | stringconditional | The command to install the CLI. |
url | stringconditional | A URL pointing to the binary or source code. |
description | string | The description for the installation method. Markdown may be used for rich text representation. |
GlobalObject
properties that apply to all commands
Fields
| Field Name | Type | Description |
|---|---|---|
exitCodes | [ExitCodeObject] | The list of possible error codes that the CLI can return. Command-specific exit codes can be defined at the command-level. |
config | object | An object where each property key is a supported file format and each property value is the path to a config file of that format; the defined paths are the expected locations of those config iles. Once defined, |
flags | [FlagItemObject] | A flag for a command. |
CommandItemObject
Describes a command for the CLI.
Fields
| Field Name | Type | Description |
|---|---|---|
summary | string | A short summary of the command. This will appear in generated help output and documentation in addition to the description. Markdown may be used for rich text representation. |
description | string | A longer description of the command. This will appear in generated help output and documentation in addition to the summary. Markdown may be used for rich text representation. |
aliases | [string] | Alternative names for a given command, e.g. |
args | [ArgumentItemObject] | The positional arguments available for the command. The order in which the arguments are defined is the order in which they should be provided to the command. |
flags | [FlagItemObject] | The flags available for the command. Flags can be provided in any order. |
hidden | boolean | Determines if the command is hidden from generated help output and documentation. Note that the command is still documented in the OpenCLI document itself and so you should not include anything sensitive. Typically developer helper functions or alternative testing commands may be hidden. |
group | boolean | If true, then the command it is a logical grouping of subcommands and is not an executable as a stand-alone command. |
exitCodes | [ExitCodeObject] | The exit code returned by the CLI upon termination to report its execution status. |
examples | [object] |
ArgumentItemObject
A positional argument for a command.
Fields
| Field Name | Type | Description |
|---|---|---|
name | stringrequired | The name of the argument. |
type | Type | The type of the argument. Codegen tools MAY use this field to coerce argument types before passing them to the command handler implementations. |
variadic | boolean | Indicates if the the argument value is variadic. Multiple values for variadic argumuments can be supplied. A variadic argument must be the last argument declared and only one variadic argument may be declared. |
minItems | integer | The minimum number of items the variadic argument must receive. Only applicable when variadic is true. |
maxItems | integer | The maximum number of items the variadic argument may receive. Only applicable when variadic is true. |
choices | [object] | The enumerated choices available for the argument. Codegen tools MAY enforce this enumeration before passing them to the command handler implementations. This will appear in generated help output and documentation. Markdown may be used for rich text representation. |
summary | string | A short summary of the argument. This will appear in generated help output and documentation in addition to the description. Markdown may be used for rich text representation. |
description | string | A description of the argument. This will appear in generated help output and documentation in addition to the summary. Markdown may be used for rich text representation. |
required | boolean | Determines if the argument is mandatory. If required arguments are not supplied, the command will exit in error. |
FlagItemObject
A flag for a command.
Fields
| Field Name | Type | Description |
|---|---|---|
name | stringrequired | The name of the flag. |
aliases | [string] | The single character short flag. |
type | Typerequired | The type of the flag. Codegen tools WILL use this field to coerce flag types before passing them to the command handler implementations. |
variadic | boolean | Indicates if the the flag value is variadic. Variadic flags can be supplied multiple times. e.g.: |
minItems | integer | The minimum number of items the variadic flag must receive. Only applicable when variadic is true. |
maxItems | integer | The maximum number of items the variadic flag may receive. Only applicable when variadic is true. |
choices | [object] | The enumerated choices available for the flag. If the flag is not one of the choices, the command will exit in error. |
hint | string | A hint to the user about the value of the flag. This will appear in generated help output and documentation. |
summary | string | A short summary of the flag. This will appear in generated help output and documentation in addition to the description. Markdown may be used for rich text representation. |
description | string | A description of the flag. This will appear in generated help output and documentation in addition to the summary. Markdown may be used for rich text representation. |
required | boolean | Determines if the flag is mandatory. If required flags are not supplied, the command will exit in error. |
default | string | number | integer | boolean | default is the default value the flag will take if it is not provided in the command line. It can be a constant or it can be sourced from the environment or a file. If sourced, resolution will be attempted from each source in the order it is defined, stopping once a value is found or the sources have been exhausted. |
alternativeSources | [AlternativeSource] | The possible sources of the default value; order is important as it determines the order of resolution. |
hidden | boolean | Determines if the flag is hidden from generated help output and documentation. |
AlternativeSource
Fields
| Field Name | Type | Description |
|---|---|---|
type | stringrequired | The name of the source; it can be
|
property | stringrequired | The variable name within the environment or JSON path to the property in the config file. |
ExitCodeObject
The exit code returned by the CLI upon termination to report its execution status.
Fields
| Field Name | Type | Description |
|---|---|---|
code | integerrequired | The literal code that is returned by the CLI to the operating system and/or parent process indicating status. Non-zero codes indicate an error. |
status | stringrequired | The enumerated exit code categories. These help the users quickly understand the scope of the error.
|
summary | stringrequired | A brief, one-line summary of the exit code. |
description | string | A detailed description of the exit code; can include expected side effects or triage steps. |
Type
The types available to specify for arguments and flags.
Enum Values
stringnumberintegerboolean