Sha256: 8a85bdd4afbc1384b7af8d8d4c20c73b4bc76b286e79a903973d61783e3e3d52

Contents?: true

Size: 575 Bytes

Versions: 6

Compression:

Stored size: 575 Bytes

Contents

require 'conjur/command'

class Conjur::Command::Field < Conjur::Command
  self.prefix = :field
  
  desc "Selects a field from structured input"
  arg_name "pattern (value | STDIN)"
  command :select do |c|
    c.action do |global_options,options,args|
      pattern = require_arg(args, 'pattern')
      value = args.shift || STDIN.read
      
      require 'json'
      json = JSON.parse(value)
      class << json
        def get_binding
          record = self
          
          binding
        end
      end
      puts json.get_binding.eval(pattern)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
conjur-cli-2.1.9 lib/conjur/command/field.rb
conjur-cli-2.1.8 lib/conjur/command/field.rb
conjur-cli-2.1.7 lib/conjur/command/field.rb
conjur-cli-2.1.6 lib/conjur/command/field.rb
conjur-cli-2.1.5 lib/conjur/command/field.rb
conjur-cli-2.1.4 lib/conjur/command/field.rb