module CommandKit::Env

Provides access to environment variables.

## Examples

class MyCmd
  include CommandKit::Env

  def main
    home = env['HOME']
    # ...
  end
end

## Testing

Can be initialized with a custom `env` hash for testing purposes.

MyCmd.new(env: {...})

Attributes

env[R]

The environment variables hash.

@return [Hash{String => String}]

@api public

Public Class Methods

new(env: ENV, **kwargs) click to toggle source

Initializes {#env}.

@param [Hash{String => String}] env

The given environment for the command. Defaults to the global `ENV`.

@param [Hash{Symbol => Object}] kwargs

Additional keyword arguments.

@api public

Calls superclass method
# File lib/command_kit/env.rb, line 41
def initialize(env: ENV, **kwargs)
  @env = env

  super(**kwargs)
end