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

class Pry
  class Command
    class ClearScreen < Pry::ClassCommand
      match 'clear-screen'
      group 'Input and Output'
      description 'Clear the contents of the screen/window Pry is running in.'

      def process
        if Pry::Helpers::Platform.windows?
          pry_instance.config.system.call(pry_instance.output, 'cls', pry_instance)
        else
          pry_instance.config.system.call(pry_instance.output, 'clear', pry_instance)
        end
      end
      Pry::Commands.add_command(self)
    end
  end
end