Class: CurseClient::CLI

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

Instance Method Summary collapse

Instance Method Details

#install(modpack_name, path = modpack_name) ⇒ Object



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

def install(modpack_name, path = modpack_name)
  modpack = client.find_by_name(modpack_name)
  if modpack
    client.install(modpack, path, options[:version])
  else
    puts "Cannot find modpack #{modpack_name}"
  end
end

#listObject



8
9
10
11
12
# File 'lib/curse_client/cli.rb', line 8

def list
  client.modpacks.each do |modpack|
    puts simple_description(modpack)
  end
end

#search(regexp) ⇒ Object



15
16
17
18
19
# File 'lib/curse_client/cli.rb', line 15

def search(regexp)
  client.modpacks.
    select { |m| m[:name] =~ /#{regexp}/i }.
    each { |m| puts simple_description(m) }
end

#show(modpack_name) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/curse_client/cli.rb', line 22

def show(modpack_name)
  modpack = client.find_by_name(modpack_name)

  if modpack
    puts modpack[:name]
    puts "Summary: #{modpack[:summary]}"
    puts "Authors: #{modpack[:authors].map{|a| a[:name]}.join(", ")}"
    puts "Url: #{modpack[:web_site_url]}"
    puts "Categories: #{modpack[:categories].map{|c| c[:name]}.join(", ")}"
    puts "Downloads: #{modpack[:download_count]}"
    puts "Popularity: #{modpack[:popularity_score]}"
    puts "Files:"
    client.addon_files(modpack[:id]).each do |f|
      puts "   #{f[:id]}    #{f[:file_date]}    #{f[:game_version].first}    #{f[:file_name]} (#{f[:release_type]})"
    end
  else
    puts "Cannot find modpack #{modpack_name}"
  end
end