mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-21 05:52:41 +08:00
docs(@angular/cli): add comments for Command interface
This commit is contained in:
parent
3bb6548d15
commit
86d803e80a
@ -84,18 +84,56 @@ export interface Option {
|
|||||||
*/
|
*/
|
||||||
description: string;
|
description: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of option value. If multiple types exist, this type will be the first one, and the
|
||||||
|
* types array will contain all types accepted.
|
||||||
|
*/
|
||||||
type: OptionType | 'suboption';
|
type: OptionType | 'suboption';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@see type}
|
||||||
|
*/
|
||||||
types?: OptionType[];
|
types?: OptionType[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aliases supported by this option.
|
||||||
|
*/
|
||||||
aliases: string[];
|
aliases: string[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this option is required or not.
|
||||||
|
*/
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format field of this option.
|
||||||
|
*/
|
||||||
format?: string;
|
format?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this option should be hidden from the help output. It will still show up in JSON help.
|
||||||
|
*/
|
||||||
hidden?: boolean;
|
hidden?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default value of this option.
|
||||||
|
*/
|
||||||
default?: string | number | boolean;
|
default?: string | number | boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this option can be used as an argument, the position of the argument. Otherwise omitted.
|
||||||
|
*/
|
||||||
positional?: number;
|
positional?: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smart default object.
|
||||||
|
*/
|
||||||
$default?: OptionSmartDefault;
|
$default?: OptionSmartDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope of the command.
|
||||||
|
*/
|
||||||
export enum CommandScope {
|
export enum CommandScope {
|
||||||
InProject = 'in',
|
InProject = 'in',
|
||||||
OutProject = 'out',
|
OutProject = 'out',
|
||||||
@ -116,7 +154,14 @@ export enum CommandType {
|
|||||||
* A description of a command, its metadata.
|
* A description of a command, its metadata.
|
||||||
*/
|
*/
|
||||||
export interface CommandDescription {
|
export interface CommandDescription {
|
||||||
|
/**
|
||||||
|
* Name of the command.
|
||||||
|
*/
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Short description (1-2 lines) of this command.
|
||||||
|
*/
|
||||||
description: string;
|
description: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,15 +174,40 @@ export interface CommandDescription {
|
|||||||
*/
|
*/
|
||||||
usageNotes?: string;
|
usageNotes?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of all supported options.
|
||||||
|
*/
|
||||||
options: Option[];
|
options: Option[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aliases supported for this command.
|
||||||
|
*/
|
||||||
aliases: string[];
|
aliases: string[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope of the command, whether it can be executed in a project, outside of a project or
|
||||||
|
* anywhere.
|
||||||
|
*/
|
||||||
scope: CommandScope;
|
scope: CommandScope;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of command.
|
||||||
|
*/
|
||||||
type: CommandType;
|
type: CommandType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this command should be hidden from a list of all commands.
|
||||||
|
*/
|
||||||
|
hidden: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constructor of the command, which should be extending the abstract Command<> class.
|
||||||
|
*/
|
||||||
impl: CommandConstructor;
|
impl: CommandConstructor;
|
||||||
|
|
||||||
hidden: boolean;
|
/**
|
||||||
|
* Suboptions.
|
||||||
|
*/
|
||||||
suboptions?: {
|
suboptions?: {
|
||||||
[name: string]: Option[];
|
[name: string]: Option[];
|
||||||
};
|
};
|
||||||
|
@ -187,6 +187,7 @@ export async function parseJsonSchemaToOptions(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const type = types[0];
|
||||||
const $default = current.$default;
|
const $default = current.$default;
|
||||||
const $defaultIndex = (json.isJsonObject($default) && $default['$source'] == 'argv')
|
const $defaultIndex = (json.isJsonObject($default) && $default['$source'] == 'argv')
|
||||||
? $default['index'] : undefined;
|
? $default['index'] : undefined;
|
||||||
@ -204,7 +205,7 @@ export async function parseJsonSchemaToOptions(
|
|||||||
const option: Option = {
|
const option: Option = {
|
||||||
name,
|
name,
|
||||||
description: '' + (current.description === undefined ? '' : current.description),
|
description: '' + (current.description === undefined ? '' : current.description),
|
||||||
...types.length == 1 ? { type: types[0] } : { type: types[0], types },
|
...types.length == 1 ? { type } : { type, types },
|
||||||
...defaultValue !== undefined ? { default: defaultValue } : {},
|
...defaultValue !== undefined ? { default: defaultValue } : {},
|
||||||
required,
|
required,
|
||||||
aliases,
|
aliases,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user