CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/rex/ui/text/input/stdio.rb
Views: 11704
1
# -*- coding: binary -*-
2
3
module Rex
4
module Ui
5
module Text
6
7
###
8
#
9
# This class implements input against standard in.
10
#
11
###
12
class Input::Stdio < Rex::Ui::Text::Input
13
14
#
15
# Reads text from standard input.
16
#
17
def sysread(len = 1)
18
$stdin.sysread(len)
19
end
20
21
#
22
# Wait for a line of input to be read from standard input.
23
#
24
def gets
25
return $stdin.gets
26
end
27
28
#
29
# Returns whether or not EOF has been reached on stdin.
30
#
31
def eof?
32
$stdin.closed?
33
end
34
35
#
36
# Returns the file descriptor associated with standard input.
37
#
38
def fd
39
return $stdin
40
end
41
end
42
43
end
44
end
45
end
46
47