Skip to content

Commit c2ccf5b

Browse files
Added default values
1 parent 03286b1 commit c2ccf5b

2 files changed

Lines changed: 86 additions & 85 deletions

File tree

draft.md

Lines changed: 80 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ This document is licensed under the MIT license
2020
| 2025-08-06 | Patrik Svensson | Remove `ordinal` property from [Argument Object](#argument-object) |
2121
| 2025-08-06 | Patrik Svensson | Add `recursive` property to [Option Object](#option-object) |
2222
| 2025-08-06 | Patrik Svensson | Add `summary` property to [CliInfo Object](#cliinfo-object) |
23+
| 2025-10-04 | Patrik Svensson | Add default values to schema |
2324
</details>
2425

2526
## Introduction
@@ -97,115 +98,115 @@ This text is the only normative description of the format.
9798

9899
This is the root object of the OpenCLI Description.
99100

100-
| Field Name | Type | Description |
101-
|------------|:----:|-------------|
102-
| opencli | `string` | **REQUIRED** The OpenCLI version number |
103-
| info | [CliInfo Object](#cliinfo-object) | **REQUIRED** Information about the CLI |
104-
| conventions | [Conventions Object](#conventions-object) | The conventions used by the CLI |
105-
| arguments | [[Argument Object](#argument-object)] | Root command arguments |
106-
| options | [[Option Object](#option-object)] | Root command options |
107-
| commands | [[Command Object](#command-object)] | Root command sub commands |
108-
| exitCodes | [[ExitCode Object](#exitcode-object)] | Root command exit codes |
109-
| examples | [`string`] | Examples of how to use the CLI |
110-
| interactive | `bool` | Indicates whether or not the command requires interactive input |
111-
| metadata | [[Metadata Object](#metadata-object)] | Custom metadata |
101+
| Field Name | Type | Default Value | Description |
102+
|------------|:----:|---------------|-------------|
103+
| opencli | `string` | - | **REQUIRED** The OpenCLI version number |
104+
| info | [CliInfo Object](#cliinfo-object) | - | **REQUIRED** Information about the CLI |
105+
| conventions | [Conventions Object](#conventions-object) | - | The conventions used by the CLI |
106+
| arguments | [[Argument Object](#argument-object)] | - | Root command arguments |
107+
| options | [[Option Object](#option-object)] | - | Root command options |
108+
| commands | [[Command Object](#command-object)] | - | Root command sub commands |
109+
| exitCodes | [[ExitCode Object](#exitcode-object)] | - | Root command exit codes |
110+
| examples | [`string`] | - | Examples of how to use the CLI |
111+
| interactive | `bool` | `false` | Indicates whether or not the command requires interactive input |
112+
| metadata | [[Metadata Object](#metadata-object)] | - | Custom metadata |
112113

113114
#### CliInfo Object
114115

115-
| Field Name | Type | Description |
116-
|------------|:----:|-------------|
117-
| title | `string` | **REQUIRED** The application title |
118-
| summary | `string` | A short summary of the application |
119-
| description | `string` | A description of the application |
120-
| contact | [Contact Object](#contact-object) | The contact information |
121-
| license | [License Object](#license-object) | The application license |
122-
| version | `string` | **REQUIRED** The application version |
116+
| Field Name | Type | Default Value | Description |
117+
|------------|:----:|---------------|-------------|
118+
| title | `string` | - | **REQUIRED** The application title |
119+
| summary | `string` | - | A short summary of the application |
120+
| description | `string` | - | A description of the application |
121+
| contact | [Contact Object](#contact-object) | - | The contact information |
122+
| license | [License Object](#license-object) | - | The application license |
123+
| version | `string` | - | **REQUIRED** The application version |
123124

124125
#### Conventions Object
125126

126-
| Field Name | Type | Description |
127-
|------------|:----:|-------------|
128-
| groupOptions | `bool` | Whether or not grouping of short options are allowed |
129-
| optionArgumentSeparator | `string` | The option argument separator |
127+
| Field Name | Type | Default Value | Description |
128+
|------------|:----:|---------------|-------------|
129+
| groupOptions | `bool` | `true` | Whether or not grouping of short options are allowed |
130+
| optionArgumentSeparator | `string` | U+0020 (space) | The option argument separator |
130131

131132
#### Contact Object
132133

133-
| Field Name | Format | Description |
134-
|------------|:------:|-------------|
135-
| name | `string` | The identifying name of the contact person/organization |
136-
| url | `string` | The URI for the contact information. This MUST be in the form of a URI |
137-
| email | `string` | The email address of the contact person/organization. This MUST be in the form of an email address |
134+
| Field Name | Format | Default Value | Description |
135+
|------------|:------:|---------------|-------------|
136+
| name | `string` | - | The identifying name of the contact person/organization |
137+
| url | `string` | - | The URI for the contact information. This MUST be in the form of a URI |
138+
| email | `string` | - | The email address of the contact person/organization. This MUST be in the form of an email address |
138139

139140
#### License Object
140141

141-
| Field Name | Type | Description |
142-
|------------|:----:|-------------|
143-
| name | `string` | The license name |
144-
| identifier | `string` | The [SPDX](https://spdx.org/licenses/) license identifier |
142+
| Field Name | Type | Default Value | Description |
143+
|------------|:----:|---------------|-------------|
144+
| name | `string` | - | The license name |
145+
| identifier | `string` | - | The [SPDX](https://spdx.org/licenses/) license identifier |
145146

146147
#### Command Object
147148

148-
| Field Name | Type | Description |
149-
|------------|:----:|-------------|
150-
| name | `string` | **REQUIRED** The command name |
151-
| aliases | [`string`] | The command aliases |
152-
| options | [[Option Object](#option-object)] | The command's options |
153-
| arguments | [[Argument Object](#argument-object)] | The command's arguments |
154-
| commands | [[Command Object](#command-object)] | The command's sub commands |
155-
| exitCodes | [[ExitCode Object](#exitcode-object)] | The command's exit codes |
156-
| description | `string` | The command description |
157-
| hidden | `bool` | Whether or not the command is hidden |
158-
| examples | [`string`] | Examples of how to use the command |
159-
| interactive | `bool` | Indicates whether or not the command requires interactive input |
160-
| metadata | [[Metadata Object](#metadata-object)] | Custom metadata |
149+
| Field Name | Type | Default Value | Description |
150+
|------------|:----:|---------------|-------------|
151+
| name | `string` | - | **REQUIRED** The command name |
152+
| aliases | [`string`] | - | The command aliases |
153+
| options | [[Option Object](#option-object)] | - | The command's options |
154+
| arguments | [[Argument Object](#argument-object)] | - | The command's arguments |
155+
| commands | [[Command Object](#command-object)] | - | The command's sub commands |
156+
| exitCodes | [[ExitCode Object](#exitcode-object)] | - | The command's exit codes |
157+
| description | `string` | - | The command description |
158+
| hidden | `bool` | `false` | Whether or not the command is hidden |
159+
| examples | [`string`] | - | Examples of how to use the command |
160+
| interactive | `bool` | `false` | Indicates whether or not the command requires interactive input |
161+
| metadata | [[Metadata Object](#metadata-object)] | - | Custom metadata |
161162

162163
#### Argument Object
163164

164-
| Field Name | Type | Description |
165-
|------------|:----:|-------------|
166-
| name | `string` | **REQUIRED** The argument name |
167-
| required | `bool` | Whether or not the argument is required |
168-
| arity | [Arity Object](#arity-object) | The argument arity. Arity defines the minimum and maximum number of argument values |
169-
| acceptedValues | [`string`] | A list of accepted values |
170-
| group | `string` | The argument group |
171-
| decription | `string` | The argument description |
172-
| hidden | `bool` | Whether or not the argument is hidden |
173-
| metadata | [[Metadata Object](#metadata-object)] | Custom metadata |
165+
| Field Name | Type | Default Value | Description |
166+
|------------|:----:|---------------|-------------|
167+
| name | `string` | - | **REQUIRED** The argument name |
168+
| required | `bool` | `false` | Whether or not the argument is required |
169+
| arity | [Arity Object](#arity-object) | - | The argument arity. Arity defines the minimum and maximum number of argument values |
170+
| acceptedValues | [`string`] | - | A list of accepted values |
171+
| group | `string` | - | The argument group |
172+
| decription | `string` | - | The argument description |
173+
| hidden | `bool` | `false` | Whether or not the argument is hidden |
174+
| metadata | [[Metadata Object](#metadata-object)] | - | Custom metadata |
174175

175176
#### Option Object
176177

177-
| Field Name | Type | Description |
178-
|------------|:----:|-------------|
179-
| name | `string` | **REQUIRED** The option name |
180-
| required | `bool` | Whether or not the option is required |
181-
| aliases | [`string`] | The option's aliases |
182-
| arguments | [[Argument](#argument-object)] | The option's arguments |
183-
| group | `string` | The option group |
184-
| description | `string` | The option description |
185-
| recursive | `bool` | Specifies whether the option is accessible from the immediate parent command and, recursively, from its subcommands |
186-
| hidden | `bool` | Whether or not the option is hidden |
187-
| metadata | [[Metadata Object](#metadata-object)] | Custom metadata |
178+
| Field Name | Type | Default Value | Description |
179+
|------------|:----:|---------------|-------------|
180+
| name | `string` | - | **REQUIRED** The option name |
181+
| required | `bool` | `false` | Whether or not the option is required |
182+
| aliases | [`string`] | - | The option's aliases |
183+
| arguments | [[Argument](#argument-object)] | - | The option's arguments |
184+
| group | `string` | - | The option group |
185+
| description | `string` | - | The option description |
186+
| recursive | `bool` | `false` | Specifies whether the option is accessible from the immediate parent command and, recursively, from its subcommands |
187+
| hidden | `bool` | `false` | Whether or not the option is hidden |
188+
| metadata | [[Metadata Object](#metadata-object)] | - | Custom metadata |
188189

189190
#### Arity Object
190191

191-
| Field Name | Type | Description |
192-
|------------|:----:|-------------|
193-
| minimum | `int` | The minimum number of values allowed |
194-
| maximum | `int` | The maximum number of values allowed |
192+
| Field Name | Type | Default Value | Description |
193+
|------------|:----:|---------------|-------------|
194+
| minimum | `int` | `1` | The minimum number of values allowed |
195+
| maximum | `int` | `1` | The maximum number of values allowed. If not specified (`nil`), unlimited number of items are allowed |
195196

196197
#### ExitCode Object
197198

198-
| Field Name | Type | Description |
199-
|------------|:----:|-------------|
200-
| code | `int` | **REQUIRED** The exit code |
201-
| description | `string` | The exit code description |
199+
| Field Name | Type | Default Value | Description |
200+
|------------|:----:|---------------|-------------|
201+
| code | `int` | - | **REQUIRED** The exit code |
202+
| description | `string` | - | The exit code description |
202203

203204
#### Metadata Object
204205

205-
| Field Name | Type | Description |
206-
|------------|:----:|-------------|
207-
| name | `string` | **REQUIRED** The metadata name |
208-
| value | `object` | The metadata value |
206+
| Field Name | Type | Default Value | Description |
207+
|------------|:----:|---------------|-------------|
208+
| name | `string` | - | **REQUIRED** The metadata name |
209+
| value | `object` | - | The metadata value |
209210

210211
[bcp14]: https://tools.ietf.org/html/bcp14
211212
[rfc2119]: https://tools.ietf.org/html/rfc2119

typespec/main.tsp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ model OpenCLI {
3131
examples?: string[];
3232

3333
@doc("Indicates whether or not the command requires interactive input")
34-
interactive?: boolean;
34+
interactive?: boolean = false;
3535

3636
@doc("Custom metadata")
3737
metadata?: Metadata[];
@@ -115,7 +115,7 @@ model Command {
115115
examples?: string[];
116116

117117
@doc("Indicate whether or not the command requires interactive input")
118-
interactive?: boolean;
118+
interactive?: boolean = false;
119119

120120
@doc("Custom metadata")
121121
metadata?: Metadata[];
@@ -126,7 +126,7 @@ model Argument {
126126
name: string;
127127

128128
@doc("Whether or not the argument is required")
129-
required?: boolean;
129+
required?: boolean = false;
130130

131131
@doc("The argument arity. Arity defines the minimum and maximum number of argument values")
132132
arity?: Arity;
@@ -152,7 +152,7 @@ model Option {
152152
name: string;
153153

154154
@doc("Whether or not the option is required")
155-
required?: boolean;
155+
required?: boolean = false;
156156

157157
@doc("The option's aliases")
158158
@uniqueItems
@@ -189,11 +189,11 @@ model ExitCode {
189189
model Arity {
190190
@doc("The minimum number of values allowed")
191191
@minValue(0)
192-
minimum?: integer;
192+
minimum?: integer = 1;
193193

194194
@doc("The maximum number of values allowed")
195195
@minValue(0)
196-
maximum?: integer;
196+
maximum?: integer = 1;
197197
}
198198

199199
model Metadata {

0 commit comments

Comments
 (0)