| | |
| | | export function parseCommand(cmd) { |
| | | "use strict"; |
| | | Object.defineProperty(exports, "__esModule", { value: true }); |
| | | exports.parseCommand = void 0; |
| | | function parseCommand(cmd) { |
| | | const extraSpacesStrippedCommand = cmd.replace(/\s{2,}/g, ' '); |
| | | const splitCommand = extraSpacesStrippedCommand.split(/\s+(?![^[]*]|[^<]*>)/); |
| | | const bregex = /\.*[\][<>]/g; |
| | |
| | | const parsedCommand = { |
| | | cmd: firstCommand.replace(bregex, ''), |
| | | demanded: [], |
| | | optional: [], |
| | | optional: [] |
| | | }; |
| | | splitCommand.forEach((cmd, i) => { |
| | | let variadic = false; |
| | |
| | | if (/^\[/.test(cmd)) { |
| | | parsedCommand.optional.push({ |
| | | cmd: cmd.replace(bregex, '').split('|'), |
| | | variadic, |
| | | variadic |
| | | }); |
| | | } |
| | | else { |
| | | parsedCommand.demanded.push({ |
| | | cmd: cmd.replace(bregex, '').split('|'), |
| | | variadic, |
| | | variadic |
| | | }); |
| | | } |
| | | }); |
| | | return parsedCommand; |
| | | } |
| | | exports.parseCommand = parseCommand; |