lib/sample_cmdlet_patterns/commands/progress_bar_twin.rb
# Execute ProgressBarTwin subcommand taking input from
# a input stream and writing to output stream
#
# sample: output.puts 'OK'
Execute ProgressBarTwin subcommand taking input from
a input stream and writing to output stream


Execute ProgressBarTwin subcommand taking input from a input stream and writing to output stream
def execute(input: $stdin, output: $stdout)
        prompt.ok('twin progress bars')
        bars = TTY::ProgressBar::Multi.new("main [:bar] :percent")
        bar1 = bars.register("one [:bar] :percent", total: 15)
        bar2 = bars.register("two [:bar] :percent", total: 100)
        bars.start
        th1 = Thread.new { 15.times { sleep(0.1); bar1.advance } }
        th2 = Thread.new { 100.times { sleep(0.05); bar2.advance } }
        [th1, th2].each { |t| t.join }
        :gui
      end
def execute ( input : $stdin , output : $stdout ) prompt . ok ( 'twin progress bars' ) bars = TTY :: ProgressBar :: Multi . new ( "main [:bar] :percent" ) bar1 = bars . register ( "one [:bar] :percent" , total : 15 ) bar2 = bars . register ( "two [:bar] :percent" , total : 100 ) bars . start th1 = Thread . new { 15 . times { sleep ( 0.1 ) ; bar1 . advance } } th2 = Thread . new { 100 . times { sleep ( 0.05 ) ; bar2 . advance } } [ th1 , th2 ] . each { | t | t . join } :gui end
Execute ProgressBarTwin subcommand taking input from
a input stream and writing to output stream
Execute ProgressBarTwin subcommand taking input from a input stream and writing to output stream
input
output