Skip to content

Commit 86d803e

Browse files
committed
docs(@angular/cli): add comments for Command interface
1 parent 3bb6548 commit 86d803e

File tree

2 files changed

+73
-2
lines changed

2 files changed

+73
-2
lines changed

packages/angular/cli/models/interface.ts

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,56 @@ export interface Option {
8484
*/
8585
description: string;
8686

87+
/**
88+
* The type of option value. If multiple types exist, this type will be the first one, and the
89+
* types array will contain all types accepted.
90+
*/
8791
type: OptionType | 'suboption';
92+
93+
/**
94+
* {@see type}
95+
*/
8896
types?: OptionType[];
8997

98+
/**
99+
* Aliases supported by this option.
100+
*/
90101
aliases: string[];
102+
103+
/**
104+
* Whether this option is required or not.
105+
*/
91106
required?: boolean;
107+
108+
/**
109+
* Format field of this option.
110+
*/
92111
format?: string;
112+
113+
/**
114+
* Whether this option should be hidden from the help output. It will still show up in JSON help.
115+
*/
93116
hidden?: boolean;
117+
118+
/**
119+
* Default value of this option.
120+
*/
94121
default?: string | number | boolean;
122+
123+
/**
124+
* If this option can be used as an argument, the position of the argument. Otherwise omitted.
125+
*/
95126
positional?: number;
127+
128+
/**
129+
* Smart default object.
130+
*/
96131
$default?: OptionSmartDefault;
97132
}
98133

134+
/**
135+
* Scope of the command.
136+
*/
99137
export enum CommandScope {
100138
InProject = 'in',
101139
OutProject = 'out',
@@ -116,7 +154,14 @@ export enum CommandType {
116154
* A description of a command, its metadata.
117155
*/
118156
export interface CommandDescription {
157+
/**
158+
* Name of the command.
159+
*/
119160
name: string;
161+
162+
/**
163+
* Short description (1-2 lines) of this command.
164+
*/
120165
description: string;
121166

122167
/**
@@ -129,15 +174,40 @@ export interface CommandDescription {
129174
*/
130175
usageNotes?: string;
131176

177+
/**
178+
* List of all supported options.
179+
*/
132180
options: Option[];
133181

182+
/**
183+
* Aliases supported for this command.
184+
*/
134185
aliases: string[];
186+
187+
/**
188+
* Scope of the command, whether it can be executed in a project, outside of a project or
189+
* anywhere.
190+
*/
135191
scope: CommandScope;
192+
193+
/**
194+
* Type of command.
195+
*/
136196
type: CommandType;
137197

198+
/**
199+
* Whether this command should be hidden from a list of all commands.
200+
*/
201+
hidden: boolean;
202+
203+
/**
204+
* The constructor of the command, which should be extending the abstract Command<> class.
205+
*/
138206
impl: CommandConstructor;
139207

140-
hidden: boolean;
208+
/**
209+
* Suboptions.
210+
*/
141211
suboptions?: {
142212
[name: string]: Option[];
143213
};

packages/angular/cli/utilities/json-schema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ export async function parseJsonSchemaToOptions(
187187
}
188188
}
189189

190+
const type = types[0];
190191
const $default = current.$default;
191192
const $defaultIndex = (json.isJsonObject($default) && $default['$source'] == 'argv')
192193
? $default['index'] : undefined;
@@ -204,7 +205,7 @@ export async function parseJsonSchemaToOptions(
204205
const option: Option = {
205206
name,
206207
description: '' + (current.description === undefined ? '' : current.description),
207-
...types.length == 1 ? { type: types[0] } : { type: types[0], types },
208+
...types.length == 1 ? { type } : { type, types },
208209
...defaultValue !== undefined ? { default: defaultValue } : {},
209210
required,
210211
aliases,

0 commit comments

Comments
 (0)