Sha256: b82ffe6635fb2c9e717f0e2fa5f2c12a2022ebc47de8837ccf877943b9af8461

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

module Conjur
  class Command
    @@api = nil
    
    class << self
      attr_accessor :prefix
      
      def method_missing *a
        Conjur::CLI.send *a
      end
      
      def command name, *a, &block
        Conjur::CLI.command "#{prefix}:#{name}", *a, &block
      end
      
      def require_arg(args, name)
        args.shift or raise "Missing parameter: #{name}"
      end

      def api
        @@api ||= Conjur::Authn.connect
      end

      def conjur_account
        Conjur::Core::API.conjur_account
      end
      
      def acting_as_option(command)
        command.arg_name 'Perform all actions as the specified Group'
        command.flag [:"as-group"]

        command.arg_name 'Perform all actions as the specified Role'
        command.flag [:"as-role"]
      end

      def display(obj, options = {})
        str = if obj.respond_to?(:attributes)
          JSON.pretty_generate obj.attributes
        elsif obj.respond_to?(:id)
          obj.id
        else
          JSON.pretty_generate obj
        end
        puts str
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
conjur-cli-2.6.0 lib/conjur/command.rb
conjur-cli-2.4.1 lib/conjur/command.rb
conjur-cli-2.4.0 lib/conjur/command.rb
conjur-cli-2.3.0 lib/conjur/command.rb
conjur-cli-2.2.1 lib/conjur/command.rb
conjur-cli-2.1.9 lib/conjur/command.rb