View on GitHub
Normalize IO streams, allowing for redirection of
+input+ and/or +output+, for example:
$ foo # => read from terminal I/O
$ foo in # => read from 'in' file, output to terminal output stream
$ foo in out # => read from 'in' file, output to 'out' file
$ foo < in > out # => equivalent to above (essentially)
Optionally a +block+ may be supplied, in which case
IO will be reset once the block has executed.
command :foo do |c|
c.syntax = 'foo [input] [output]'
c.when_called do |args, options|
# or io(args.shift, args.shift)
str = $stdin.gets
puts 'input was: ' + str.inspect
- Describe what "UI.io" returns.