Class: Grundler::CLI
- Inherits:
-
Object
- Object
- Grundler::CLI
- Defined in:
- lib/grundler.rb
Instance Method Summary collapse
- #arguments ⇒ Object
- #current_command ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #lockfile_path ⇒ Object
- #nodule_path ⇒ Object
Constructor Details
#initialize ⇒ CLI
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
#arguments ⇒ Object
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_command ⇒ Object
23 24 25 |
# File 'lib/grundler.rb', line 23 def current_command COMMANDS.find { |c| ARGV.first == c }&.capitalize || "Help" end |
#lockfile_path ⇒ Object
39 40 41 |
# File 'lib/grundler.rb', line 39 def lockfile_path LOCKFILE_PATH end |
#nodule_path ⇒ Object
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 |