// extractFlags snacks out targeted flags (and their values) from argv in place.
export function extractFlags(args, keys) {
    const flags = {};
    let index = 0;
    while (index < args.length) {
        const token = args[index];
        if (token === undefined || !keys.includes(token)) {
            index += 1;
            continue;
        }
        const value = args[index + 1];
        if (value === undefined) {
            throw new Error(`Flag '${token}' requires a value.`);
        }
        flags[token] = value;
        args.splice(index, 2);
    }
    return flags;
}
// expectValue asserts that a flag is followed by a value.
export function expectValue(flag, value) {
    if (value === undefined) {
        throw new Error(`Flag '${flag}' requires a value.`);
    }
    return value;
}
//# sourceMappingURL=flag-utils.js.map