Sha256: 0fefdd79a84be1edc15da8e03906de6794a3670c3f7a113623f34ba2867be1f6

Contents?: true

Size: 866 Bytes

Versions: 8

Compression:

Stored size: 866 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

8 entries across 8 versions & 1 rubygems

Version Path
flammarion-utils-0.2.1 bin/fwrap
flammarion-utils-0.2.0 bin/fwrap
flammarion-utils-0.1.14 bin/fwrap
flammarion-utils-0.1.13 bin/fwrap
flammarion-utils-0.1.12 bin/fwrap
flammarion-utils-0.1.11 bin/fwrap
flammarion-utils-0.1.10pre2 bin/fwrap
flammarion-utils-0.1.10pre bin/fwrap