Class: Grundler::CLI

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

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



18
19
20
21
# File 'lib/grundler.rb', line 18

def initialize
  json_writer = PackageJsonWriter.new(lockfile_path)
  Grundler::Commands.const_get(current_command).new(self, arguments, json_writer)
end

Instance Method Details

#argumentsObject



27
28
29
30
31
# File 'lib/grundler.rb', line 27

def arguments
  @switches = ARGV.select { |a| a[0] == "-" }

  ARGV.drop(1) - @switches
end

#current_commandObject



23
24
25
# File 'lib/grundler.rb', line 23

def current_command
  COMMANDS.find { |c| ARGV.first == c }&.capitalize || "Help"
end

#lockfile_pathObject



39
40
41
# File 'lib/grundler.rb', line 39

def lockfile_path
  LOCKFILE_PATH
end

#nodule_pathObject



33
34
35
36
37
# File 'lib/grundler.rb', line 33

def nodule_path
  @nodule_path ||=
    (JSON.parse(File.read(LOCKFILE_PATH))["nodulePath"] if File.exist?(LOCKFILE_PATH)) ||
    DEFAULT_NODULE_PATH
end