<commit_before>require 'formatador'
require 'optparse'
require 'ostruct'

module Orchestrator

  class Cli

    def self.parse(args)
      options = OpenStruct.new
      options.args = Object.new

      parser = OptionParser.new
      parser.banner = "Usage: #{$0} [options]"

      options.config = Orchestrator::Settings
      parser.on( '--config [PATH]', 'Path to settings yaml' ) do |config|
        options.config = config
        options.args.instance_variable_set(:@config,config)
      end

      options.statefile = nil
      options.name = nil
      parser.on( '--name NAME', 'Name of the cron job to run' ) do |name|
        options.name = name
        options.args.instance_variable_set(:@name,name)
      end

      parser.on( '--statefile PATH', 'Path to state file yaml' ) do |statefile|
        options.statefile = statefile
        options.args.instance_variable_set(:@statefile,statefile)
      end

      options.reset = false
      parser.on( '--reset', 'Do not use state file if it exists' ) { |reset| options.reset = true }

      parser.on( '--args ARGS,', Array, 'extra args for interpolation as arg1=val1,arg2=val2,...]' ) do |extra_args|
        extra_args.each do |extra_arg|<commit_msg>better options parsing<commit_after>require 'formatador'
require 'optparse'
require 'ostruct'

module Orchestrator

  class Cli

    def self.parse(args)
      options = OpenStruct.new
      options.args = Object.new

      parser = OptionParser.new
      parser.banner = "Usage: #{$0} [options]"

      options.config = Orchestrator::Settings
      parser.on( '--config PATH', String, 'Path to settings yaml' ) do |config|
        options.config = config
        options.args.instance_variable_set(:@config,config)
      end

      options.statefile = nil
      options.name = nil
      parser.on( '--name NAME', 'Name of the cron job to run' ) do |name|
        options.name = name
        options.args.instance_variable_set(:@name,name)
      end

      parser.on( '--statefile PATH', String, 'Path to state file yaml' ) do |statefile|
        options.statefile = statefile
        options.args.instance_variable_set(:@statefile,statefile)
      end

      options.reset = false
      parser.on( '--reset', 'Do not use state file if it exists' ) { |reset| options.reset = true }

      parser.on( '--args ARGS,', Array, 'extra args for interpolation as arg1=val1,arg2=val2,...]' ) do |extra_args|
        extra_args.each do |extra_arg|
{'fraction_non_alphanumeric': 0.11903791275988586, 'fraction_numerical': 0.0040766408479412965, 'mean_word_length': 2.7465648854961833, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4002690', 'n_tokens_mistral': 770, 'n_tokens_neox': 731, 'n_words': 205}