summaryrefslogtreecommitdiff
path: root/lib/pry/commands/fix_indent.rb
blob: 6c338691dae14cbe70987ad674370fee673ea54b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

class Pry
  class Command
    class FixIndent < Pry::ClassCommand
      match 'fix-indent'
      group 'Input and Output'

      description "Correct the indentation for contents of the input buffer"

      banner <<-USAGE
        Usage: fix-indent
      USAGE

      def process
        indented_str = Pry::Indent.indent(eval_string)
        eval_string.replace indented_str
      end
    end

    Pry::Commands.add_command(Pry::Command::FixIndent)
  end
end