Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <files...>.
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'
Comment on lines +24 to +26
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The properties command and version used here do not align with the cli.schema.json. According to the schema, the root cli object should have a name property (which is required), not command. Additionally, the version property is not defined in the schema for the cli object. To maintain consistency with the schema and other examples in this file, you should use name and remove version.

Suggested change
command: cli-schema
description: Canonical JSON Schema for declarative CLI definitions
version: '1.0.6'
name: cli-schema
description: Canonical JSON Schema for declarative CLI definitions


# 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 <files...>.
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
```

---
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 24 additions & 23 deletions examples/cli-schema.definition.yml
Original file line number Diff line number Diff line change
@@ -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'
Comment on lines +4 to +6
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The properties command and version are not valid under the cli object according to schema/cli.schema.json. The schema requires a name property and does not define a version property at this level. This will cause validation to fail. Please use name instead of command and remove the version property to align with the schema.

  name: cli-schema
  description: Canonical JSON Schema for declarative CLI definitions


# 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 <files...>.
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 <files...>.
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
Comment on lines +21 to +28
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The alias property is not valid for an option definition. According to schema/cli.schema.json, you should use short for the single-letter alias of an option. The alias property is valid for commands, but not for options. This is also inconsistent with the corresponding example in EXAMPLES.md.

    - name: help
      short: h
      description: display help for command
      type: boolean
    - name: version
      short: V
      description: output the version number
      type: boolean

3 changes: 2 additions & 1 deletion schema/cli.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,6 @@
],
"additionalProperties": false
}
}
},
"required": ["cli"]
}