Sha256: 88f0c387d0e86d8f34dfef7ede19d17056911f843936afe71320687fbe459c5d

Contents?: true

Size: 538 Bytes

Versions: 10

Compression:

Stored size: 538 Bytes

Contents

command "run" do |c|
  c.syntax = "#{$datapimp_cli} run FILE"
  c.description = "runs a script in the context of the datapimp config"

  c.option '--format FORMAT', String, 'which format should we serialize the result? json default'

  c.action do |args, options|
    code = ""

    args.each do |arg|
      code += Pathname(arg).read
    end

    result = begin
      eval(code)
    rescue
      {error: $!}
    end

    if options.format == "json"
      puts JSON.generate(result) if result
    else
      puts result
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
datapimp-1.2.11 lib/datapimp/cli/run.rb
datapimp-1.2.10 lib/datapimp/cli/run.rb
datapimp-1.2.9 lib/datapimp/cli/run.rb
datapimp-1.2.8 lib/datapimp/cli/run.rb
datapimp-1.2.7 lib/datapimp/cli/run.rb
datapimp-1.2.6 lib/datapimp/cli/run.rb
datapimp-1.2.5 lib/datapimp/cli/run.rb
datapimp-1.2.4 lib/datapimp/cli/run.rb
datapimp-1.2.3 lib/datapimp/cli/run.rb
datapimp-1.2.2 lib/datapimp/cli/run.rb