summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert <r-obert@users.noreply.github.com>2017-12-26 12:53:48 +0100
committerGitHub <noreply@github.com>2017-12-26 12:53:48 +0100
commitb6d3e9e22e6845c39fddc661d726b31f283c74fe (patch)
tree36c3e21fda2dde940396f99f8928ae64165959e8
parent61e03c93ae570582dc1da575d627920dc09928a2 (diff)
downloadpry-b6d3e9e22e6845c39fddc661d726b31f283c74fe.tar.gz
Add a new command, "clear-screen", that clears the content of the (#1723)
screen Pry is running in regardless of platform (Windows or UNIX-like).
-rw-r--r--CHANGELOG.md3
-rw-r--r--lib/pry/commands/clear_screen.rb14
2 files changed, 17 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b64a45b8..56669c41 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,9 @@
#### Features
+* Add a new command, "clear-screen", that clears the content of the
+ screen Pry is running in regardless of platform (Windows or UNIX-like).
+
* Add a new command, "gem-stat", inspired by the rubygem of a similar
name (gem-stats) by [@dannytatom](https://github.com/dannytatom).
diff --git a/lib/pry/commands/clear_screen.rb b/lib/pry/commands/clear_screen.rb
new file mode 100644
index 00000000..30781b2a
--- /dev/null
+++ b/lib/pry/commands/clear_screen.rb
@@ -0,0 +1,14 @@
+class Pry::Command::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 windows?
+ _pry_.config.system.call(_pry_.output, 'cls', _pry_)
+ else
+ _pry_.config.system.call(_pry_.output, 'clear', _pry_)
+ end
+ end
+ Pry::Commands.add_command(self)
+end