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.



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

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

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv.



7
8
9
# File 'lib/dotenv/cli.rb', line 7

def argv
  @argv
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/dotenv/cli.rb', line 13

def run
  filenames = parse_filenames || []
  begin
    Dotenv.load!(*filenames)
  rescue Errno::ENOENT => e
    abort e.message
  else
    exec(*argv) unless argv.empty?
  end
end