<commit_before>require 'masamune'
require 'thor'
require 'pry'

module Masamune::Tasks
  class ShellThor < Thor
    include Masamune::Thor
    include Masamune::Actions::DataFlow

    # FIXME need to add an unnecessary namespace until this issue is fixed:
    # https://github.com/wycats/thor/pull/247
    namespace :shell

    desc 'shell', 'Launch an interactive shell'
    method_option :dump, :type => :boolean, :desc => 'Dump SQL schema'
    method_option :type, :enum => ['psql', 'hql'], :desc => 'Schema type', :default => 'psql'
    class_option :start, :aliases => '-a', :desc => 'Start time', default: '1 month ago'
    def shell_exec
      print_registry; exit if options[:dump]
      Pry.start self, prompt: proc { 'masamune> ' }
    end
    default_task :shell_exec

    private

    def print_registry
      case options[:type]
      when 'psql'
        puts registry.as_psql
      when 'hql'
        puts registry.as_hql
      end
    end
  end
end<commit_msg>Fix --dump exit<commit_after>require 'masamune'
require 'thor'
require 'pry'

module Masamune::Tasks
  class ShellThor < Thor
    include Masamune::Thor
    include Masamune::Actions::DataFlow

    # FIXME need to add an unnecessary namespace until this issue is fixed:
    # https://github.com/wycats/thor/pull/247
    namespace :shell

    desc 'shell', 'Launch an interactive shell'
    method_option :dump, :type => :boolean, :desc => 'Dump SQL schema', :default => false
    method_option :type, :enum => ['psql', 'hql'], :desc => 'Schema type', :default => 'psql'
    class_option :start, :aliases => '-a', :desc => 'Start time', default: '1 month ago'
    def shell_exec
      if options[:dump]
        print_registry
        exit
      end

      Pry.start self, prompt: proc { 'masamune> ' }
    end
    default_task :shell_exec

    private

    def print_registry
      case options[:type]
      when 'psql'
        puts registry.as_psql
      when 'hql'
        puts registry.as_hql
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11367050575863796, 'fraction_numerical': 0.00400600901352028, 'mean_word_length': 2.90234375, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, 'https://': 2, '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': '3375792', 'n_tokens_mistral': 641, 'n_tokens_neox': 627, 'n_words': 196}