Skip to content

Commit

Permalink
#1272: allow extended identifier names "id", "key", "name"
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Apr 19, 2024
1 parent 56f2323 commit 2eb99b9
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -744,18 +744,21 @@ function metadataToTypeKey(
}
case 3: {
switch (itemArr[1]) {
case 'key':
case 'k': {
if (allowedIdentifiers.includes('key')) {
return { type: itemArr[0], key: itemArr[2] };
}
break;
}
case 'id':
case 'i': {
if (allowedIdentifiers.includes('id')) {
return { type: itemArr[0], id: itemArr[2] };
}
break;
}
case 'name':
case 'n': {
if (allowedIdentifiers.includes('name')) {
return { type: itemArr[0], name: itemArr[2] };
Expand All @@ -767,16 +770,18 @@ function metadataToTypeKey(
});
const response = {};
for (const item of metadataOptionMap) {
if (item.key || item.id || item.name) {
if (!response[item.type]) {
response[item.type] = [];
}
response[item.type].push(
item.key || (item.id ? 'id:' + item.id : item.name ? 'name:' + item.name : null)
);
} else {
if (!response[item.type]) {
response[item.type] = null;
if (item) {
if (item.key || item.id || item.name) {
if (!response[item.type]) {
response[item.type] = [];
}
response[item.type].push(
item.key || (item.id ? 'id:' + item.id : item.name ? 'name:' + item.name : null)
);
} else {
if (!response[item.type]) {
response[item.type] = null;
}
}
}
}
Expand Down

0 comments on commit 2eb99b9

Please sign in to comment.