lib/cli.rb in inqlude-0.7.4 vs lib/cli.rb in inqlude-0.8.0
- old
+ new
@@ -24,12 +24,17 @@
def self.settings= s
@@settings = s
end
- def self.distro= d
- @@distro = d
+ def self.distro
+ @@distro if @@distro
+
+ @@distro = Distro.detect
+ if !@@distro
+ STDERR.puts "Warning: unable to detect distro."
+ end
end
desc "global", "Global options", :hide => true
def global
if options[:version]
@@ -37,12 +42,12 @@
qmake_out = `qmake -v`
qmake_out =~ /Qt version (.*) in/
puts "Qt: #{$1}"
- if @@distro
- puts "OS: #{@@distro.name} #{@@distro.version}"
+ if self.distro
+ puts "OS: #{self.distro.name} #{self.distro.version}"
else
puts "OS: unknown"
end
else
Cli.help shell
@@ -61,11 +66,11 @@
if options[:remote]
handler.libraries.each do |library|
puts library.name + " (" + library.versions.join(", ") + ")"
end
else
- manifests = @@distro.installed handler
+ manifests = self.distro.installed handler
manifests.each do |manifest|
puts manifest["name"]
end
end
end
@@ -121,24 +126,29 @@
result.print_result
else
handler = ManifestHandler.new @@settings
handler.read_remote
count_ok = 0
+ count_warning = 0
handler.libraries.each do |library|
library.manifests.each do |manifest|
result = v.verify manifest
result.print_result
if result.valid?
count_ok += 1
else
errors.push result
end
+ if result.has_warnings?
+ count_warning +=1
+ end
end
end
puts
puts "#{handler.manifests.count} manifests checked. #{count_ok} ok, " +
- "#{errors.count} with error."
+ "#{errors.count} with error, " +
+ "#{count_warning} #{count_warning == 1 ? "has warning." : "have warnings."}"
if !errors.empty?
puts
puts "Errors:"
errors.each do |error|
puts " #{error.name}"
@@ -261,11 +271,11 @@
handler = ManifestHandler.new @@settings
manifest = handler.manifest name
if !manifest
STDERR.puts "Manifest for '#{name}' not found"
else
- @@distro.uninstall manifest
+ self.distro.uninstall manifest
end
end
desc "install", "Install library"
method_option :dry_run, :type => :boolean,
@@ -274,10 +284,10 @@
handler = ManifestHandler.new @@settings
manifest = handler.manifest name
if !manifest
STDERR.puts "Manifest for '#{name}' not found"
else
- @@distro.install manifest, :dry_run => options[:dry_run]
+ self.distro.install manifest, :dry_run => options[:dry_run]
end
end
desc "download", "Download source code archive"
def download(name)