This commit is contained in:
Qiaoqiao Zhang 2020-08-14 09:41:39 +08:00 коммит произвёл GitHub
Родитель 1928d83e65
Коммит a52eb8cfc7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 36 добавлений и 21 удалений

Просмотреть файл

@ -175,27 +175,21 @@ function getCommandBody(model: CodeModelAz, needGeneric: boolean = false, debug:
// this is to handle names like "format", "type", etc
if (parameterName.endsWith("_")) {
argument = " c.argument('" + parameterName + "'";
argument += ", options_list=['--" + parameterName.substr(0, parameterName.length - 1) + "']";
model.MethodParameter.language['az']['alias'] = Array(parameterName.substr(0, parameterName.length - 1));
} else if (parameterName.endsWith('name') && parameterName.replace(/_name$|_/g, '') == model.CommandGroup_DefaultName.toLowerCase() || !isNullOrUndefined(model.MethodParameter?.language?.['cli']?.['alias'])) {
argument = " c.argument('" + parameterName + "'";
let aliases: string[] = [];
if(!model.Method['hasName']) {
aliases.push('name');
aliases.push('n');
if (isNullOrUndefined(model.MethodParameter.language['az']['alias'])) {
model.MethodParameter.language['az']['alias'] = [];
}
if(!isNullOrUndefined(model.MethodParameter?.language?.['cli']?.['alias'])) {
let alias = model.MethodParameter?.language?.['cli']?.['alias'];
if(typeof alias === "string") {
aliases.push(alias);
}
if (isArray(alias)) {
aliases = aliases.concat(alias);
}
model.MethodParameter.language['az']['alias'].push(parameterName.substr(0, parameterName.length - 1));
} else if (parameterName.endsWith('name') && !model.Method['hasName'] && parameterName.replace(/_name$|_/g, '') == model.CommandGroup_DefaultName.toLowerCase()) {
if (isNullOrUndefined(model.MethodParameter.language['az']['alias'])) {
model.MethodParameter.language['az']['alias'] = [];
}
model.MethodParameter.language['az']['alias'].push('name');
model.MethodParameter.language['az']['alias'].push('n');
}
if (!isNullOrUndefined(model.MethodParameter.language['az']['alias'])) {
argument = " c.argument('" + parameterName + "'";
let aliases = model.MethodParameter.language['az']['alias'];
if(aliases.length > 0) {
let alias_str = [];
let ori_alias = [];

Просмотреть файл

@ -3,7 +3,8 @@ import { Session, startSession, Host, Channel } from "@azure-tools/autorest-exte
import { serialize, deserialize } from "@azure-tools/codegen";
import { values, items, length, Dictionary } from "@azure-tools/linq";
import { changeCamelToDash } from '../utils/helper';
import { isNullOrUndefined } from "util";
import { isNullOrUndefined, isArray } from "util";
import { type } from "os";
export class AzNamer {
codeModel: CodeModel;
@ -183,12 +184,32 @@ export class AzNamer {
operation.parameters.forEach(parameter => {
if(!isNullOrUndefined(parameter.language['cli'])) {
this.getAzName(parameter);
if (!isNullOrUndefined(parameter.language['cli']['alias'])) {
parameter.language['az']['alias'] = []
if (typeof(parameter.language['cli']['alias']) == "string") {
parameter.language['az']['alias'].push(changeCamelToDash(parameter.language['cli']['alias']));
} else if (isArray(parameter.language['cli']['alias'])) {
for(let alias of parameter.language['cli']['alias']) {
parameter.language['az']['alias'].push(changeCamelToDash(alias));
}
}
}
}
});
if(request.parameters) {
request.parameters.forEach(parameter => {
if(parameter.language['cli'] != undefined) {
if(!isNullOrUndefined(parameter.language['cli'])) {
this.getAzName(parameter);
if (!isNullOrUndefined(parameter.language['cli']['alias'])) {
parameter.language['az']['alias'] = []
if (typeof(parameter.language['cli']['alias']) == "string") {
parameter.language['az']['alias'].push(changeCamelToDash(parameter.language['cli']['alias']));
} else if (isArray(parameter.language['cli']['alias'])) {
for(let alias of parameter.language['cli']['alias']) {
parameter.language['az']['alias'].push(changeCamelToDash(alias));
}
}
}
}
});
}