<commit_before># encoding: utf-8

require 'highline'
require 'rainbow'
require 'singularity_dsl'
require 'terminal-table'
require 'thor'

# required for DSL in .singularity.rb to just work
include SingularityDsl

module SingularityDsl
  # CLI Thor task
  class Cli < Thor
    class_option :script,
                 aliases: '-s',
                 type: :string,
                 desc: 'Specify path to a .singularity.rb file',
                 default: './.singularity.rb'
    class_option :debug,
                 aliases: '-d',
                 type: :boolean,
                 desc: 'Turn on debug mode'

    desc 'test', 'Run singularity script.'
    def test
      SingularityDsl.load_tasks
      load File.expand_path options[:script]
    end

    desc 'tasks', 'Available tasks.'
    def tasks
      headers = [Rainbow('Task').yellow, Rainbow('Description').yellow]
      table = Terminal::Table.new headings: headers
      table.style = { border_x: '', border_y: '', border_i: '' }
      SingularityDsl.task_list.each do |task|
        name = task_name task
        desc = task_description task
        table.add_row [name, desc]
      end
      say table
    end
  end
end
<commit_msg>[refactor]: adding singularity_script util fx<commit_after># encoding: utf-8

require 'highline'
require 'rainbow'
require 'singularity_dsl'
require 'terminal-table'
require 'thor'

# required for DSL in .singularity.rb to just work
include SingularityDsl

module SingularityDsl
  # CLI Thor task
  class Cli < Thor
    class_option :script,
                 aliases: '-s',
                 type: :string,
                 desc: 'Specify path to a .singularity.rb file',
                 default: './.singularity.rb'
    class_option :debug,
                 aliases: '-d',
                 type: :boolean,
                 desc: 'Turn on debug mode'

    desc 'test', 'Run singularity script.'
    def test
      SingularityDsl.load_tasks
      say Rainbow("Loading CI script from #{singularity_script} ...").blue
      load singularity_script
    end

    desc 'tasks', 'Available tasks.'
    def tasks
      headers = [Rainbow('Task').yellow, Rainbow('Description').yellow]
      table = Terminal::Table.new headings: headers
      table.style = { border_x: '', border_y: '', border_i: '' }
      SingularityDsl.task_list.each do |task|
        name = task_name task
        desc = task_description task
        table.add_row [name, desc]
      end
      say table
    end

    private
      def singularity_script
        File.expand_path options[:script]
      end
  end
end

{'fraction_non_alphanumeric': 0.0979020979020979, 'fraction_numerical': 0.000777000777000777, 'mean_word_length': 2.21875, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1849064', 'n_tokens_mistral': 778, 'n_tokens_neox': 732, 'n_words': 224}