const { injectParameters } = require('../src/lib/parameter_injector');

function readArg(name, fallback) {
  const index = process.argv.indexOf(`--${name}`);
  if (index === -1 || index + 1 >= process.argv.length) return fallback;
  return process.argv[index + 1];
}

function readNumber(name, fallback) {
  const value = Number(readArg(name, fallback));
  return Number.isFinite(value) ? value : fallback;
}

function main() {
  const seed = readArg('seed', 'mazex-injector-demo');
  const expression = readArg('expr', 'x + y');
  const count = readNumber('count', 3);
  const minOperatorScore = readNumber('min-score', 1);
  const maxOperatorScore = readNumber('max-score', 1000);
  const numberMin = readNumber('number-min', 1);
  const numberMax = readNumber('number-max', 1000);

  const result = injectParameters({
    expression,
    seed,
    count,
    minOperatorScore,
    maxOperatorScore,
    numberMin,
    numberMax,
  });

  console.log(JSON.stringify(result, null, 2));
}

main();
