lib/u3d/commands.rb in u3d-0.9.1 vs lib/u3d/commands.rb in u3d-0.9.2

- old
+ new

@@ -24,10 +24,11 @@ require 'u3d/downloader' require 'u3d/installer' require 'u3d/cache' require 'u3d/utils' require 'u3d/log_analyzer' +require 'u3d/unity_runner' require 'u3d_core/command_executor' require 'u3d_core/credentials' require 'fileutils' module U3d @@ -38,11 +39,18 @@ list = Installer.create.installed if list.empty? UI.important 'No Unity version installed' return end - list.each do |u| + # version -> installations + arraym = list.map{|a| [a.version, a]} + map = Hash[*arraym.flatten] + # sorted versions + vcomparators = map.keys.map { |k| UnityVersionComparator.new(k) } + sorted_keys = vcomparators.sort.map { |v| v.version.to_s } + sorted_keys.each do |k| + u = map[k] UI.message "Version #{u.version}\t(#{u.path})" packages = u.packages next unless options[:packages] && packages && !packages.empty? UI.message 'Packages:' packages.each { |pack| UI.message " - #{pack}" } @@ -137,14 +145,11 @@ end end end return if options[:no_install] - files.each do |name, file, info| - UI.verbose "Installing #{name}#{info['mandatory'] ? ' (mandatory package)' : ''}, with file #{file}" - Installer.install_module(file, version, installation_path: options[:installation_path], info: info) - end + Installer.install_modules(files, version, installation_path: options[:installation_path]) end def local_install(args: [], options: {}) UI.user_error!('Please specify a version') if args.empty? version = args[0] @@ -180,13 +185,10 @@ files << [package, result[0], result[1]] unless result.nil? end end end - files.each do |name, file, info| - UI.verbose "Installing #{name}#{info['mandatory'] ? ' (mandatory package)' : ''}, with file #{file}" - Installer.install_module(file, version, installation_path: options[:installation_path], info: info) - end + Installer.install_modules(files, version, installation_path: options[:installation_path]) end def run(options: {}, run_args: []) version = options[:unity_version]