Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Commit

Permalink
fix-issue-352 (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
qiaozha authored May 9, 2020
1 parent b4512d5 commit 3d7fae9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ debug-output-folder: $(az-output-folder)/_az_debug

use-extension:
"@autorest/python": "5.0.0-preview.3"
"@autorest/clicommon": "0.4.7"
"@autorest/clicommon": "0.4.8"
#"@autorest/python": "latest"

cli:
Expand Down
43 changes: 27 additions & 16 deletions src/plugins/azgenerator/CodeModelAzImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,30 +84,41 @@ export class CodeModelCliImpl implements CodeModelAz {
}


private getOrder(op: string) {
if(op.indexOf(" ") > -1) {
op = op.split(" ")[1];
}
let opOrder = ["list", "show", "create", "update", "delete"];
let order = opOrder.indexOf(op.toLowerCase()) + 1;
if (order == 0) {
order = opOrder.length + 1;
}
return order;
}

private sortOperationByAzCommand() {
for (let [idx, operationGroup] of this.codeModel.operationGroups.entries()) {
operationGroup.operations.sort((a, b) => {
let oa = this.getOrder(a.language['az']['name']) + "_" + a.language['az']['name'] + "_" + (100 - a.parameters.length);
let ob = this.getOrder(b.language['az']['name']) + "_" + b.language['az']['name'] + "_" + (100 - b.parameters.length);
return oa.localeCompare(ob);
operationGroup.operations.sort(function(a, b) {
function getOrder(op: string) {
if(op.indexOf(" ") > -1) {
op = op.split(" ").last;
}
let opOrder = ["list", "show", "create", "update", "delete"];
let order = opOrder.indexOf(op.toLowerCase()) + 1;
if (order == 0) {
order = opOrder.length + 1;
}
return order;
}
let oa = getOrder(a.language['az']['name']);
let ob = getOrder(b.language['az']['name']);
if(oa < ob) {
return -1;
} else if(oa > ob) {
return 1;
} else {
let la = a.language['az']['name'];
let lb = b.language['az']['name'];
if(la != lb) {
return la.localeCompare(lb);
}
return a.parameters.length > b.parameters.length? -1: 1;
}
});
this.codeModel.operationGroups[idx] = operationGroup;
}

}


public get RandomizeNames(): boolean {
if (this.options?.['randomize-names']) return true;
return false;
Expand Down

0 comments on commit 3d7fae9

Please sign in to comment.