Class: Dotenv::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/dotenv/cli.rb

Overview

The CLI is a class responsible of handling all the command line interface logic.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv = []) ⇒ CLI

Returns a new instance of CLI.



12
13
14
15
# File 'lib/dotenv/cli.rb', line 12

def initialize(argv = [])
  @argv = argv.dup
  @filenames = []
end

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv.



10
11
12
# File 'lib/dotenv/cli.rb', line 10

def argv
  @argv
end

#filenamesObject (readonly)

Returns the value of attribute filenames.



10
11
12
# File 'lib/dotenv/cli.rb', line 10

def filenames
  @filenames
end

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/dotenv/cli.rb', line 17

def run
  parse_argv!(@argv)

  begin
    Dotenv.load!(*@filenames)
  rescue Errno::ENOENT => e
    abort e.message
  else
    exec(*@argv) if @argv.present?
  end
end