Sha256: 52d79cdd7b2b28a3c3ef6cdfd4adc6d74a916410b8612e818621978ba0f02bfe

Contents?: true

Size: 530 Bytes

Versions: 11

Compression:

Stored size: 530 Bytes

Contents

command "run" do |c|
  c.syntax = "datapimp 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

11 entries across 11 versions & 1 rubygems

Version Path
datapimp-1.2.1 lib/datapimp/cli/run.rb
datapimp-1.2.0 lib/datapimp/cli/run.rb
datapimp-1.1.1 lib/datapimp/cli/run.rb
datapimp-1.1.0 lib/datapimp/cli/run.rb
datapimp-1.0.29 lib/datapimp/cli/run.rb
datapimp-1.0.28 lib/datapimp/cli/run.rb
datapimp-1.0.27 lib/datapimp/cli/run.rb
datapimp-1.0.26 lib/datapimp/cli/run.rb
datapimp-1.0.25 lib/datapimp/cli/run.rb
datapimp-1.0.24 lib/datapimp/cli/run.rb
datapimp-1.0.23 lib/datapimp/cli/run.rb