Class: GemPaths::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/gem_paths/cli.rb

Instance Method Summary collapse

Instance Method Details

#listObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gem_paths/cli.rb', line 9

def list
  defaults = {"format" => "make"}
  opt = defaults.merge(options)
  begin
    case opt['format']
    when 'yaml'
      puts GemPaths::List.to_yaml
    when 'json'
      puts GemPaths::List.to_json
    when 'make'
      puts GemPaths::List.to_make
    when 'sh'
      puts GemPaths::List.to_sh
    else
      shell.error set_color("Invalid value for --format option. Try 'gempaths help list' for more info.", Thor::Shell::Color::RED)
      exit(2)
    end
  rescue
    shell.error set_color("Unexpected error occurred. Please make sure you have a Gemfile.lock file in your project.", Thor::Shell::Color::RED)
    exit(3)
  end
end