lib/cli.rb in inqlude-0.8.0 vs lib/cli.rb in inqlude-0.9.0

- old
+ new

@@ -24,33 +24,14 @@ def self.settings= s @@settings = s end - 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] - puts "Inqlude: #{@@settings.version}" - - qmake_out = `qmake -v` - qmake_out =~ /Qt version (.*) in/ - puts "Qt: #{$1}" - - if self.distro - puts "OS: #{self.distro.name} #{self.distro.version}" - else - puts "OS: unknown" - end + CliController.print_versions(Distro.detect) else Cli.help shell end end @@ -66,11 +47,11 @@ if options[:remote] handler.libraries.each do |library| puts library.name + " (" + library.versions.join(", ") + ")" end else - manifests = self.distro.installed handler + manifests = Distro.detect.installed handler manifests.each do |manifest| puts manifest["name"] end end end @@ -83,24 +64,41 @@ method_option :enable_disqus, :type => :boolean, :desc => "Enable Disqus based comments on generate web pages. Works only on actual domain." method_option :disable_search, :type => :boolean, :desc => "Disable Google based search." + method_option :templates, :type => :string, :aliases => "-t", :default => "one-column", + :desc => "Switch templates", :required => false def view process_global_options options + output_dir = options[:output_dir] + if options[:manifest_dir] @@settings.manifest_path = options[:manifest_dir] end 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] + + view.templates = options[:templates] + + if !view.template_directory_exists? + STDERR.puts "Error: Templates directory doesn't exist" + exit 1 + else + puts "Creating web site in '#{output_dir}' from '#{manifest_handler.settings.manifest_path}'" + + view.enable_disqus = options[:enable_disqus] + view.enable_search = !options[:disable_search] + + view.create output_dir + end + end desc "show <library_name>", "Show library details" def show name Upstream.get_involved "Add command for showing library details", 1 @@ -271,11 +269,11 @@ handler = ManifestHandler.new @@settings manifest = handler.manifest name if !manifest STDERR.puts "Manifest for '#{name}' not found" else - self.distro.uninstall manifest + Distro.detect.uninstall manifest end end desc "install", "Install library" method_option :dry_run, :type => :boolean, @@ -284,10 +282,10 @@ handler = ManifestHandler.new @@settings manifest = handler.manifest name if !manifest STDERR.puts "Manifest for '#{name}' not found" else - self.distro.install manifest, :dry_run => options[:dry_run] + Distro.detect.install manifest, :dry_run => options[:dry_run] end end desc "download", "Download source code archive" def download(name)