Merge pull request #75 from Azure/issue-fixes

issue fixes
This commit is contained in:
Zim Kalinowski 2020-01-20 08:17:53 +08:00 коммит произвёл GitHub
Родитель d2d738b08d bdef26406a
Коммит 8996a45379
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 45 добавлений и 7 удалений

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

@ -23,7 +23,7 @@ export class CodeModelCliImpl implements CodeModelAz
async init() {
this.options = await this.session.getValue('az');
this.extensionName = await this.options['az-name'];
this.extensionName = await this.options['extensions'];
this.currentOperationGroupIndex = -1;
this.currentOperationIndex = -1;
this.currentParameterIndex = -1;
@ -133,7 +133,7 @@ export class CodeModelCliImpl implements CodeModelAz
public get CommandGroup_Name(): string
{
return this.codeModel.operationGroups[this.currentOperationGroupIndex].$key;
return this.extensionName + " " + ToSnakeCase(this.codeModel.operationGroups[this.currentOperationGroupIndex].$key);
}
public get CommandGroup_Help(): string
@ -240,6 +240,15 @@ export class CodeModelCliImpl implements CodeModelAz
{
if(this.codeModel.operationGroups[this.currentOperationGroupIndex].operations[this.currentOperationIndex].request.parameters.length > 0) {
this.currentParameterIndex = 0;
//this.session.message({Channel:Channel.Warning, Text: "operationGroupIndex: " + this.currentOperationGroupIndex + " operationIndex: "+ this.currentOperationIndex +" parameterIndex: " + this.currentParameterIndex})
const currentParameterName = this.codeModel.operationGroups[this.currentOperationGroupIndex].operations[this.currentOperationIndex].request.parameters[this.currentParameterIndex].language['az'].name;
if(currentParameterName == "subscription-id" || currentParameterName == "api-version" || currentParameterName == "$host") {
if(this.SelectNextOption()) {
return true;
} else {
return false;
};
}
return true;
} else {
this.currentParameterIndex = -1;
@ -251,6 +260,14 @@ export class CodeModelCliImpl implements CodeModelAz
{
if(this.currentParameterIndex < this.codeModel.operationGroups[this.currentOperationGroupIndex].operations[this.currentOperationIndex].request.parameters.length - 1) {
this.currentParameterIndex++;
const currentParameterName = this.codeModel.operationGroups[this.currentOperationGroupIndex].operations[this.currentOperationIndex].request.parameters[this.currentParameterIndex].language['az'].name;
if(currentParameterName == "subscription-id" || currentParameterName == "api-version" || currentParameterName == "$host") {
if(this.SelectNextOption()) {
return true;
} else {
return false;
};
}
return true;
} else {
this.currentParameterIndex = -1;

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

@ -34,7 +34,9 @@ export function GenerateAzureCliReport(model: CodeModelAz) : string[] {
mo.push("|------|----|-----------|----------|--------------|");
model.SelectFirstOption();
if(!model.SelectFirstOption()) {
continue;
}
// first parameters that are required
do
@ -46,7 +48,9 @@ export function GenerateAzureCliReport(model: CodeModelAz) : string[] {
}
while (model.SelectNextOption());
model.SelectFirstOption();
if(!model.SelectFirstOption()) {
continue;
}
// following by required parameters
do {

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

@ -4,18 +4,35 @@ import { serialize, deserialize } from '@azure-tools/codegen';
import { values, items, length, Dictionary } from '@azure-tools/linq';
import { changeCamelToDash } from '../utils/helper';
class AzNamer {
export class AzNamer {
codeModel: CodeModel;
constructor(protected session: Session<CodeModel>) {
this.codeModel = session.model;
}
public methodMap(operationNameOri: string, httpProtocol: string) {
let operationName = operationNameOri.toLowerCase();
httpProtocol = httpProtocol.toLowerCase();
if(operationName.startsWith("create") && httpProtocol == "put") {
return "create";
} else if(operationName.startsWith("update") && (httpProtocol == "put" || httpProtocol == "patch")) {
return "update";
} else if(operationName.startsWith("get") && httpProtocol == "get") {
return "show";
} else if(operationName.startsWith("list") && httpProtocol == "get") {
return "list";
} else if(operationName.startsWith("delete") && httpProtocol == "delete") {
return "delete";
}
return operationNameOri;
}
async process() {
let azSettings = await this.session.getValue('az');
let extensionName = azSettings['az-name'];
let extensionName = azSettings['extensions'];
//console.error(extensionName);
this.session.message({Channel:Channel.Debug, Text:"in aznamer process"});
@ -34,7 +51,7 @@ class AzNamer {
let operationName = "";
if(operation.language['cli'] != undefined) {
operation.language['az'] = {};
operation.language['az']['name'] = operation.language['cli']['name'];
operation.language['az']['name'] = this.methodMap(operation.language['cli']['name'], operation.request.protocol.http.method);
operation.language['az']['description'] = operation.language['cli']['description'];
operationName = operationGroupName + " " + changeCamelToDash(operation.language['az']['name']);
operation.language['az']['command'] = operationName;