forked from spectreconsole/open-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tsp
More file actions
205 lines (147 loc) · 4.23 KB
/
Copy pathmain.tsp
File metadata and controls
205 lines (147 loc) · 4.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
import "@typespec/json-schema";
import "./scalars.tsp";
using TypeSpec.JsonSchema;
@jsonSchema
@doc("The OpenCLI description")
model OpenCLI {
@doc("The OpenCLI version number")
opencli: string;
@doc("Information about the CLI")
info: CliInfo;
@doc("The conventions used by the CLI")
conventions?: Conventions;
@doc("Root command arguments")
arguments?: Argument[];
@doc("Root command options")
options?: Option[];
@doc("Root command sub commands")
commands?: Command[];
@doc("Root command exit codes")
exitCodes?: ExitCode[];
@doc("Examples of how to use the CLI")
examples?: string[];
@doc("Indicates whether or not the command requires interactive input")
interactive?: boolean = false;
@doc("Custom metadata")
metadata?: Metadata[];
}
model CliInfo {
@doc("The application title")
title: string;
@doc("A short summary of the application")
summary?: string;
@doc("A description of the application")
description?: string;
@doc("The contact information")
contact?: Contact;
@doc("The application license")
license?: License;
@doc("The application version")
version: string;
}
model Conventions {
@doc("Whether or not grouping of short options are allowed")
groupOptions?: boolean = true;
@doc("The option argument separator")
optionSeparator?: string = " ";
}
@doc("Contact information")
model Contact {
@doc("The identifying name of the contact person/organization")
name?: string;
@doc("The URI for the contact information. This MUST be in the form of a URI.")
url?: url;
@doc("The email address of the contact person/organization. This MUST be in the form of an email address.")
email?: email;
}
model License {
@doc("The license name")
name?: string;
@doc("The SPDX license identifier")
identifier?: string;
@doc("The URI for the license. This MUST be in the form of a URI")
url?: string;
}
model Command {
@doc("The command name")
name: string;
@doc("The command aliases")
@uniqueItems
aliases?: string[];
@doc("The command options")
options?: Option[];
@doc("The command arguments")
arguments?: Argument[];
@doc("The command's sub commands")
commands?: Command[];
@doc("The command's exit codes")
exitCodes?: ExitCode[];
@doc("The command description")
description?: string;
@doc("Whether or not the command is hidden")
hidden?: boolean = false;
@doc("Examples of how to use the command")
examples?: string[];
@doc("Indicate whether or not the command requires interactive input")
interactive?: boolean = false;
@doc("Custom metadata")
metadata?: Metadata[];
}
model Argument {
@doc("The argument name")
name: string;
@doc("Whether or not the argument is required")
required?: boolean = false;
@doc("The argument arity. Arity defines the minimum and maximum number of argument values")
arity?: Arity = #{ minimum: 1, maximum: 1 };
@doc("A list of accepted values")
acceptedValues?: string[];
@doc("The argument group")
group?: string;
@doc("The argument description")
description?: string;
@doc("Whether or not the argument is hidden")
hidden?: boolean = false;
@doc("Custom metadata")
metadata?: Metadata[];
}
model Option {
@doc("The option name")
name: string;
@doc("Whether or not the option is required")
required?: boolean = false;
@doc("The option's aliases")
@uniqueItems
aliases?: string[];
@doc("The option's arguments")
arguments?: Argument[];
@doc("The option group")
group?: string;
@doc("The option description")
description?: string;
@doc("Specifies whether the option is accessible from the immediate parent command and, recursively, from its subcommands")
recursive?: boolean = false;
@doc("Whether or not the option is hidden")
hidden?: boolean = false;
@doc("Custom metadata")
metadata?: Metadata[];
}
model ExitCode {
@doc("The exit code")
code: integer;
@doc("The exit code description")
description?: string;
}
@doc("Arity defines the minimum and maximum number of argument values")
model Arity {
@doc("The minimum number of values allowed")
@minValue(0)
minimum?: integer = 1;
@doc("The maximum number of values allowed")
@minValue(0)
maximum?: integer = 1;
}
model Metadata {
name: string;
value?: unknown;
}