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.



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

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

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv.



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

def argv
  @argv
end

#exec_argsObject (readonly)

Returns the value of attribute exec_args.



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

def exec_args
  @exec_args
end

#filenamesObject (readonly)

Returns the value of attribute filenames.



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

def filenames
  @filenames
end

#parser_argsObject (readonly)

Returns the value of attribute parser_args.



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

def parser_args
  @parser_args
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(*@exec_args) unless @exec_args.empty?
  end
end