<commit_before>class Pry
  module DefaultCommands

    Shell = Pry::CommandSet.new do

      # this cannot be accessed, it's just for help purposes.
      command ".<shell command>", "All text following a '.' is forwarded to the shell." do
      end

      command "shell-mode", "Toggle shell mode. Bring in pwd prompt and file completion." do
        case Pry.active_instance.prompt
        when Pry::SHELL_PROMPT
          Pry.active_instance.pop_prompt
          Pry.active_instance.custom_completions = Pry::DEFAULT_CUSTOM_COMPLETIONS
        else
          Pry.active_instance.push_prompt Pry::SHELL_PROMPT
          Pry.active_instance.custom_completions = Pry::FILE_COMPLETIONS
          Readline.completion_proc = Pry::InputCompleter.build_completion_proc target,
          Pry.active_instance.instance_eval(&Pry::FILE_COMPLETIONS)
        end
      end

      alias_command "file-mode", "shell-mode", ""


      command "cat", "Show output of file FILE. Type `cat --help` for more information." do |*args|
        options= {}
        file_name = nil
        start_line = 0
        end_line = -1
        file_type = nil

        OptionParser.new do |opts|
          opts.banner = %{Usage: cat [OPTIONS] FILE
Cat a file. Defaults to displaying whole file. Syntax highlights file if type is recognized.
e.g: cat hello.rb
--
}
          opts.on("-l", "--line-numbers", "Show line numbers.") do |line|
            options[:l] = true
          end

          opts.on("-s", "--start LINE", "Start line (defaults to start of file). Line 1 is the first line.") do |line|
            start_line = line.to_i - 1
          end

          opts.on("-e", "--end LINE", "End line (defaults to end of file). Line -1 is the last line.") do |line|
            end_line = line.to_i - 1
          end

          opts.on("-t", "--type TYPE", "The specific file type for syntax higlighting (e.g ruby, python, cpp, java)") do |type|
            file_type = type.to_sym
          end

          opts.on("-f", "--flood", "Do not use a pager to view text longer than one screen.") do
            options[:f] = true
          end

          opts.on_tail("-h", "--help", "This message.") do
            output.puts opts
            options[:h] = true
          end
        end.order(args) do |v|
          file_name = v
        end

        next if options[:h]

        if !file_name
          output.puts "Must provide a file name."
          next
        end

        contents, normalized_start_line, _ = read_between_the_lines(file_name, start_line, end_line)

        if Pry.color
          contents = syntax_highlight_by_file_type_or_specified(contents, file_name, file_type)
        end

        set_file_and_dir_locals(file_name)
        render_output(options[:f], options[:l] ? normalized_start_line + 1 : false, contents)
        contents
      end
<commit_msg>use Slop for shell command<commit_after>class Pry
  module DefaultCommands

    Shell = Pry::CommandSet.new do

      # this cannot be accessed, it's just for help purposes.
      command ".<shell command>", "All text following a '.' is forwarded to the shell." do
      end

      command "shell-mode", "Toggle shell mode. Bring in pwd prompt and file completion." do
        case Pry.active_instance.prompt
        when Pry::SHELL_PROMPT
          Pry.active_instance.pop_prompt
          Pry.active_instance.custom_completions = Pry::DEFAULT_CUSTOM_COMPLETIONS
        else
          Pry.active_instance.push_prompt Pry::SHELL_PROMPT
          Pry.active_instance.custom_completions = Pry::FILE_COMPLETIONS
          Readline.completion_proc = Pry::InputCompleter.build_completion_proc target,
          Pry.active_instance.instance_eval(&Pry::FILE_COMPLETIONS)
        end
      end

      alias_command "file-mode", "shell-mode", ""


      command "cat", "Show output of file FILE. Type `cat --help` for more information." do |*args|
        start_line = 0
        end_line = -1

        opts = Slop.parse!(args) do |opts|
          opts.on :s, :start, "Start line (defaults to start of file)Line 1 is the first line.", true, :as => Integer do |line|
            start_line = line - 1
          end

          opts.on :e, :end, "End line (defaults to end of file). Line -1 is the last line", true, :as => Integer do |line|
            end_line = line - 1
          end

          opts.on :l, "line-numbers", "Show line numbers."
          opts.on :t, :type, "The specific file type for syntax higlighting (e.g ruby, python)", true, :as => Symbol
          opts.on :f, :flood, "Do not use a pager to view text longer than one screen."
          opts.on :h, :help, "This message." do
            output.puts opts
          end
        end

        next if opts.help?

        file_name = args.shift
        if !file_name
          output.puts "Must provide a file name."
          next
        end

        contents, normalized_start_line, _ = read_between_the_lines(file_name, start_line, end_line)

        if Pry.color
          contents = syntax_highlight_by_file_type_or_specified(contents, file_name, opts[:type])
        end

        set_file_and_dir_locals(file_name)
        render_output(opts.flood?, opts.l? ? normalized_start_line + 1 : false, contents)
        contents
      end

{'fraction_non_alphanumeric': 0.09662664379645512, 'fraction_numerical': 0.0026681913474366306, 'mean_word_length': 2.178679588128407, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '3497524', 'n_tokens_mistral': 1616, 'n_tokens_neox': 1544, 'n_words': 481}