Sha256: 3334e1c936fa58d9d82ddb9fe381ea81b153edc651637e981631350e33c9b52d

Contents?: true

Size: 903 Bytes

Versions: 1

Compression:

Stored size: 903 Bytes

Contents

#!/usr/bin/env ruby
#
# A simple example that will wrap any command into a flammarion window.
require 'open3'
require 'flammarion'

f = Flammarion::Engraving.new(exit_on_disconnect:true)
i, o, e, t = Open3.popen3(*ARGV.to_a)

f.subpane("out").print("")

f.subpane("in").input("> ", autoclear:true, history:true) do |msg|
  i.puts msg['text']
end

f.subpane("in").button("Close (Ctrl+D)") do
  f.subpane("in").clear
  i.close
  t.value.success? ? f.status("Exit Success".light_green) : f.status("Exit code: #{t.value}".light_red)
end

Thread.new do
  while l = e.readpartial(4096)
    f.subpane("out").print l.red
  end
end

begin
  while l = o.readpartial(4096)
    f.subpane("out").print l
  end
rescue EOFError
  f.subpane("in").clear
  t.value.success? ? f.status("Exit Success".light_green) : f.status("Exit code: #{t.value}".light_red)
end

f.wait_until_closed

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flammarion-utils-0.3.0 bin/fwrap