Sha256: 3533a9e068509ce0d5afa1d5b99b14a00230d1fe70253998d83795102c909534

Contents?: true

Size: 904 Bytes

Versions: 4

Compression:

Stored size: 904 Bytes

Contents

#!/usr/bin/env ruby
# WANT_JSON

# init bundler in dev env
if ENV['QB_DEV_ENV']
  ENV.each {|k, v|
    if k.start_with? 'QB_DEV_ENV_'
      ENV[k.sub('QB_DEV_ENV_', '')] = v
    end
  }
  require 'bundler/setup'
end

require 'qb'
require 'cmds'

class Stream < QB::AnsibleModule
  def main
    template = @args['template'] || @args['cmd']
    
    if template.nil?
      raise ArgumentError,
            "Must supply `template` or `cmd` argument."
    end
    
    opts = {}
    
    [:args, :kwds, :input, :assert, :env, :chdir].each { |key|
      opts[key] = @args[key.to_s] if @args.key?(key.to_s)
    }
    
    [:format, :env_mode].each { |key|
      opts[key] = @args[key].to_sym if @args.key?(key.to_s)
    }
    
    cmd = Cmds.new(template, **opts)
    
    if @args['log']
      info "STREAMING #{ cmd.prepare.inspect }"
    end
    
    cmd.stream!
    
    changed!
  end
end

Stream.new.run

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
qb-0.3.3 library/stream
qb-0.3.2 library/stream
qb-0.3.1 library/stream
qb-0.1.88 library/stream