diff --git a/EXAMPLES.md b/EXAMPLES.md index b5bd670..1c26157 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -20,31 +20,32 @@ This file provides a self-referential example, defining the `cli-schema` command ```yaml # This file defines the 'cli-schema' command-line tool itself, # using the canonical schema. -command: cli-schema -description: Canonical JSON Schema for declarative CLI definitions -version: '1.0.6' - -# Defines the positional arguments for the command. -arguments: - - name: filesToValidate - description: One or more files to validate against the schema. - type: string - # 'required: false' makes this argument optional, equivalent to [files...]. - # If this was 'required: true', it would be equivalent to . - required: false - variadic: true - -# Defines the options (flags) for the command. -# These are standard options automatically provided by commander.js. -options: - - name: help - short: h - description: Display help for command - type: boolean - - name: version - short: V - description: Output the version number - type: boolean +cli: + command: cli-schema + description: Canonical JSON Schema for declarative CLI definitions + version: '1.0.6' + + # Defines the positional arguments for the command. + arguments: + - name: filesToValidate + description: One or more files to validate against the schema. + type: string + # 'required: false' makes this argument optional, equivalent to [files...]. + # If this was 'required: true', it would be equivalent to . + required: false + variadic: true + + # Defines the options (flags) for the command. + # These are standard options automatically provided by commander.js. + options: + - name: help + short: h + description: Display help for command + type: boolean + - name: version + short: V + description: Output the version number + type: boolean ``` --- diff --git a/README.md b/README.md index 2a7e570..7c8a912 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,8 @@ While the examples show a simple command, the schema is designed to handle enter ## Schema Reference +All CLI definitions must be nested under a top-level `cli` object. This root object contains all the commands, arguments, and options that define your command-line interface. + The `cli-schema` defines the structure for your CLI definition file. Here are the main building blocks: ### The `command` Object diff --git a/examples/cli-schema.definition.yml b/examples/cli-schema.definition.yml index e3edaea..4ba78c2 100644 --- a/examples/cli-schema.definition.yml +++ b/examples/cli-schema.definition.yml @@ -1,27 +1,28 @@ # This file defines the 'cli-schema' command-line tool itself, # using the canonical schema. -command: cli-schema -description: Canonical JSON Schema for declarative CLI definitions -version: '1.0.6' +cli: + command: cli-schema + description: Canonical JSON Schema for declarative CLI definitions + version: '1.0.6' -# Defines the positional arguments for the command. -arguments: - - name: filesToValidate - description: One or more files to validate against the schema. - type: string - # 'required: false' makes this argument optional, equivalent to [files...]. - # If this was 'required: true', it would be equivalent to . - required: false - variadic: true + # Defines the positional arguments for the command. + arguments: + - name: filesToValidate + description: One or more files to validate against the schema. + type: string + # 'required: false' makes this argument optional, equivalent to [files...]. + # If this was 'required: true', it would be equivalent to . + required: false + variadic: true -# Defines the options (flags) for the command. -# These are standard options automatically provided by commander.js. -options: - - name: help - alias: h - description: display help for command - type: boolean - - name: version - alias: V - description: output the version number - type: boolean + # Defines the options (flags) for the command. + # These are standard options automatically provided by commander.js. + options: + - name: help + alias: h + description: display help for command + type: boolean + - name: version + alias: V + description: output the version number + type: boolean diff --git a/schema/cli.schema.json b/schema/cli.schema.json index 506bf21..df76f78 100644 --- a/schema/cli.schema.json +++ b/schema/cli.schema.json @@ -126,5 +126,6 @@ ], "additionalProperties": false } - } + }, + "required": ["cli"] }