Class: Lapis::Minecraft::Versioning::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/lapis/minecraft/versioning/cli.rb

Overview

Note:

This class is not included by default with `lapis/minecraft/versioning`.

Command-line interface for retrieving version information.

Instance Method Summary collapse

Instance Method Details

#assets(id) ⇒ Object


70
71
72
73
74
75
76
# File 'lib/lapis/minecraft/versioning/cli.rb', line 70

def assets(id)
  version = version_list[id]
  max_size_length = version.assets.map { |asset| asset.size.to_s.length }.max
  version.assets.each do |asset|
    printf("%s %#{max_size_length}d %s\n", asset.sha1, asset.size, asset.path)
  end
end

#client(id) ⇒ Object


49
50
51
52
# File 'lib/lapis/minecraft/versioning/cli.rb', line 49

def client(id)
  version = version_list[id]
  puts version.client_download.url
end

#info(id) ⇒ Object


39
40
41
42
# File 'lib/lapis/minecraft/versioning/cli.rb', line 39

def info(id)
  version = version_list[id]
  display_info(version)
end

#latest(type = 'release') ⇒ Object


110
111
112
113
# File 'lib/lapis/minecraft/versioning/cli.rb', line 110

def latest(type = 'release')
  version = latest_version(type)
  display_info(version)
end

#latest_id(type = 'release') ⇒ Object


98
99
100
# File 'lib/lapis/minecraft/versioning/cli.rb', line 98

def latest_id(type = 'release')
  puts latest_version(type).id
end

#libraries(id) ⇒ Object


83
84
85
86
87
88
# File 'lib/lapis/minecraft/versioning/cli.rb', line 83

def libraries(id)
  version = version_list[id]
  version.libraries.each do |library|
    puts library.name
  end
end

#list(type = 'all') ⇒ Object


21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/lapis/minecraft/versioning/cli.rb', line 21

def list(type = 'all')
  type_sym = type.downcase.to_sym
  versions = case type_sym
               when :alpha, :beta, :snapshot, :release
                 filter(type_sym)
               else # all
                 version_list
             end
  versions.each do |version|
    puts version.id
  end
end

#server(id) ⇒ Object


59
60
61
62
# File 'lib/lapis/minecraft/versioning/cli.rb', line 59

def server(id)
  version = version_list[id]
  puts version.server_download.url
end