lib/cli.rb in inqlude-0.7.0 vs lib/cli.rb in inqlude-0.7.1

- old
+ new

@@ -18,10 +18,11 @@ default_task :global class_option :version, :type => :boolean, :desc => "Show version" class_option :offline, :type => :boolean, :desc => "Work offline" + class_option :manifest_dir, :type => :string, :desc => "Manifest directory" def self.settings= s @@settings = s end @@ -84,11 +85,14 @@ if options[:manifest_dir] @@settings.manifest_path = options[:manifest_dir] end - view = View.new ManifestHandler.new @@settings + manifest_handler = ManifestHandler.new(@@settings) + manifest_handler.read_remote + + view = View.new(manifest_handler) view.enable_disqus = options[:enable_disqus] view.enable_search = !options[:disable_search] view.create options[:output_dir] end @@ -108,31 +112,43 @@ if options[:check_links] Upstream.get_involved "Implement --check-links option", 11 exit 1 end + errors = [] + if filename result = v.verify_file filename result.print_result else handler = ManifestHandler.new @@settings handler.read_remote count_ok = 0 - count_error = 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 - count_error += 1 + errors.push result end end end + puts puts "#{handler.manifests.count} manifests checked. #{count_ok} ok, " + - "#{count_error} with error." + "#{errors.count} with error." + if !errors.empty? + puts + puts "Errors:" + errors.each do |error| + puts " #{error.name}" + error.errors.each do |e| + puts " #{e}" + end + end + end end end desc "review <repo>", "Review pull requests on GitHub. Use 'username:branch' as repo parameter." def review repo, action = nil @@ -258,12 +274,28 @@ else @@distro.install manifest, :dry_run => options[:dry_run] end end + desc "download", "Download source code archive" + def download(name) + handler = ManifestHandler.new(@@settings) + handler.read_remote + manifest = handler.manifest(name) + if !manifest + STDERR.outs "Manifest for '#{name}' not found" + exit 1 + else + Downloader.new(handler, STDOUT).download(name, Dir.pwd) + end + end + private def process_global_options options @@settings.offline = options[:offline] + if options[:manifest_dir] + @@settings.manifest_path = options[:manifest_dir] + end end end