python-archieve-projects/WechatBot/node_modules/cmd-ts/dist/esm/newparser/findOption.js

24 lines
705 B
JavaScript
Executable File

/**
* A utility function to find an option in the AST
*
* @param nodes AST node list
* @param opts Long and short names to look up
*/
export function findOption(nodes, opts) {
const result = [];
for (const node of nodes) {
if (node.type === 'longOption' && opts.longNames.includes(node.key)) {
result.push(node);
continue;
}
if (node.type === 'shortOptions' && opts.shortNames.length) {
for (const option of node.options) {
if (opts.shortNames.includes(option.key)) {
result.push(option);
}
}
}
}
return result;
}
//# sourceMappingURL=findOption.js.map