Class: Nutella::NutellaCLI

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

Constant Summary collapse

NUTELLA_LOGO =
"                   _       _ _
            | |     | | |
 _ __  _   _| |_ ___| | | __ _
|  _ \\| | | | __/ _ \\ | |/ _  |
| | | | |_| | ||  __/ | | (_| |
|_| |_|\\__,_|\\__\\___|_|_|\\__,_|
"

Class Method Summary collapse

Class Method Details

Print nutella logo



41
42
43
44
45
46
47
48
49
50
# File 'lib/core/nutella_cli.rb', line 41

def self.
  console.info(NUTELLA_LOGO)
  nutella_version = File.open("#{Nutella::NUTELLA_HOME}VERSION", 'rb').read
  console.info("Welcome to nutella version #{nutella_version}! For a complete lists of available commands type 'nutella help'\n")
  # If nutella is not ready to be used (i.e. nobody has invoked the "nutella checkup" command yet),
  # append warning/reminder message
  if  Nutella.config['ready'].nil?
    console.warn 'Looks like this is a fresh installation of nutella. Please run \'nutella checkup\' to check all dependencies are installed.'
  end
end

.run ⇒ Object

Nutella entry point. Every time the "nutella" command is invoked this is the method that gets called. It reads the command line parameters and it invokes the right sub-command



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/core/nutella_cli.rb', line 16

def self.run
  # Read parameters
  args = ARGV.dup
  args.shift

  # Check that the command is not empty, if so, simply print the nutella logo
  command = ARGV.first
  if command == nil
    
    exit 0
  end

  # If nutella is not ready to be used (i.e. nobody has invoked the "nutella checkup" command yet),
  # append warning/reminder message
  if Nutella.config['ready'].nil? && command!='checkup'
    console.warn 'Looks like this is a fresh installation of nutella. Please run \'nutella checkup\' to check all dependencies are installed.'
  end

  # Execute the appropriate command
  Nutella.execute_command command, args
  exit 0
end