daisy / ace

Ace by DAISY, an Accessibility Checker for EPUB
MIT License
74 stars 22 forks source link

Feature: Allow config overrides on command line #409

Open nverwer opened 4 months ago

nverwer commented 4 months ago

Ace 1.3.2

Sometimes it is useful to override the settings from config.json on the command line. Currently, it is not possible to change the cliConfig object, because it is frozen, and I am not sure whether not freezing it will break something.

Overriding the configuration could be done by adding something like

    config: {
      isMultiple: true,
      alias: 'C',
      type: 'string'
    }

to meowOptions. To override the options (which does not work at the moment):

  if (cli.flags.config) {
    cli.flags.config.forEach((config) => {
      const kv = config.split('=', 2);
      cliConfig[kv[0]] = JSON.parse(kv[1]);
    });
  }

I am looking at the code for the first time, so this probably does not follow coding guidelines.

Alternatively, the command line could allow individual options to be set, like --return-2-on-validation-error=true.

If someone from the ACE team gives their view on this, I could probably make a PR with the modified code.