Sha256: 01383af58a7e42498e3cb55f3861e605c4fe6c7b62c6387b6ca054f90bc58d85

Contents?: true

Size: 973 Bytes

Versions: 8

Compression:

Stored size: 973 Bytes

Contents

module Conjur
  class Command
    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
        Conjur::Authn.connect
      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

8 entries across 8 versions & 1 rubygems

Version Path
conjur-cli-2.1.8 lib/conjur/command.rb
conjur-cli-2.1.7 lib/conjur/command.rb
conjur-cli-2.1.6 lib/conjur/command.rb
conjur-cli-2.1.5 lib/conjur/command.rb
conjur-cli-2.1.4 lib/conjur/command.rb
conjur-cli-2.1.3 lib/conjur/command.rb
conjur-cli-2.1.2 lib/conjur/command.rb
conjur-cli-2.1.1 lib/conjur/command.rb