Class: Mundler::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/mundler/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


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

def self.exit_on_failure?
  true
end

Instance Method Details

#cleanObject



56
57
58
59
60
61
62
63
64
# File 'lib/mundler/cli.rb', line 56

def clean
  Mundler::Project.new(Dir.pwd).clean
rescue Interrupt
  $stderr.puts("\e[31mUser cancelled\e[0m")
  exit 1
rescue MundlefileNotFound
  $stderr.puts("\e[31mMundlefile not found in the current directory\e[0m")
  exit 1
end

#exec(*args) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/mundler/cli.rb', line 67

def exec(*args)
  Mundler::Project.new(Dir.pwd).exec(args)
rescue Interrupt
  exit 1
rescue NotInstalledError
  $stderr.puts("\e[31mChanges to the Mundlefile have been detected. Run `mundle install` and try again.\e[0m")
  exit 1
rescue MundlefileNotFound
  $stderr.puts("\e[31mMundlefile not found in the current directory\e[0m")
  exit 1
end

#installObject



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

def install
  Mundler::Project.new(Dir.pwd).install
  puts("\e[32mMundle complete!\e[0m")
rescue Mundler::CompilationError
  $stderr.puts("\e[31mMundle failed\e[0m")
  exit 1
rescue Interrupt
  $stderr.puts("\e[31mMundle failed (user cancelled)\e[0m")
  exit 1
rescue MundlefileNotFound
  $stderr.puts("\e[31mMundlefile not found in the current directory\e[0m")
  exit 1
end

#pathObject



80
81
82
83
84
85
86
87
88
# File 'lib/mundler/cli.rb', line 80

def path
  puts Mundler::Project.new(Dir.pwd).path
rescue Interrupt
  $stderr.puts("\e[31mUser cancelled\e[0m")
  exit 1
rescue MundlefileNotFound
  $stderr.puts("\e[31mMundlefile not found in the current directory\e[0m")
  exit 1
end

#summaryObject



44
45
46
47
48
49
50
51
52
53
# File 'lib/mundler/cli.rb', line 44

def summary
  project = Mundler::Project.new(Dir.pwd)
  project.print_summary
rescue Interrupt
  $stderr.puts("\e[31mUser cancelled\e[0m")
  exit 1
rescue MundlefileNotFound
  $stderr.puts("\e[31mMundlefile not found in the current directory\e[0m")
  exit 1
end

#updateObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/mundler/cli.rb', line 27

def update
  project = Mundler::Project.new(Dir.pwd)
  project.clean
  project.install
  puts("\e[32mMundle complete!\e[0m")
rescue Mundler::CompilationError
  $stderr.puts("\e[31mFailed to install\e[0m")
  exit 1
rescue Interrupt
  $stderr.puts("\e[31mUser cancelled\e[0m")
  exit 1
rescue MundlefileNotFound
  $stderr.puts("\e[31mMundlefile not found in the current directory\e[0m")
  exit 1
end