{"size": 607, "ext": "js", "max_stars_repo_path": "bin/helpers/flags.js", "max_stars_repo_name": "TiagoVenceslau/cardinal", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "bin/helpers/flags.js", "max_issues_repo_name": "TiagoVenceslau/cardinal", "max_issues_repo_issues_event_min_datetime": "2020-08-27T18:51:51.000Z", "max_issues_repo_issues_event_max_datetime": "2020-11-02T14:34:40.000Z", "max_forks_repo_path": "bin/helpers/flags.js", "max_forks_repo_name": "TiagoVenceslau/cardinal", "max_forks_repo_forks_event_min_datetime": "2020-01-27T11:49:41.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-04T18:04:21.000Z"}
{"max_stars_count": null, "max_issues_count": 2, "max_forks_count": 7, "avg_line_length": 21.6785714286, "max_line_length": 69, "alphanum_fraction": 0.5700164745}
class FlagManager {
  constructor(options = []) {
    try {
      let args = process.argv;
      if (process.env.npm_config_argv) {
        args.concat(JSON.parse(process.env.npm_config_argv).original)
      }
      this.flags = args.filter(arg => arg.substr(0, 2) === '--');
      for (const flag of options) { this.add(flag); }
    } catch (error) {
      console.error('FlagManager:', error)
      this.flags = [];
    }
  }

  get toArray() {
    return this.flags;
  }

  add(flag) {
    if (flag && !this.flags.includes(flag)) {
      this.flags.push(flag);
    }
  }
}

module.exports = FlagManager;
