8
const firstCommand = splitCommand.shift();
9
if (!firstCommand) throw new Error(`No command found in: ${cmd}`);
11
>
const parsedCommand: ParsedCommand = {
12
>
cmd: firstCommand.replace(bregex, ''),
13
>
demanded: [],
14
>
optional: [],
15
>
};
16
>
splitCommand.forEach((cmd, i) => {
17
>
let variadic = false;
18
>
cmd = cmd.replace(/\s/g, '');
19
>
if (/\.+[\]>]/.test(cmd) && i === splitCommand.length - 1) variadic = true;
20
>
if (/^\[/.test(cmd)) {
21
parsedCommand.optional.push({
22
cmd: cmd.replace(bregex, '').split('|') as NotEmptyArray<string>,
23
variadic,
24
});
26
parsedCommand.demanded.push({
27
cmd: cmd.replace(bregex, '').split('|') as NotEmptyArray<string>,