lib/gitdocs/cli.rb in gitdocs-0.5.0.pre6 vs lib/gitdocs/cli.rb in gitdocs-0.5.0.pre7

- old
+ new

@@ -1,12 +1,18 @@ +# -*- encoding : utf-8 -*- + +# rubocop:disable LineLength, ClassLength + module Gitdocs require 'thor' class Cli < Thor include Thor::Actions - def self.source_root; File.expand_path('../../', __FILE__); end + def self.source_root + File.expand_path('../../', __FILE__) + end desc 'start', 'Starts a daemonized gitdocs process' method_option :debug, type: :boolean, aliases: '-D' method_option :port, type: :string, aliases: '-p' method_option :pid, type: :string, aliases: '-P' @@ -82,12 +88,29 @@ desc 'status', 'Retrieve gitdocs status' def status say "GitDoc v#{VERSION}" say "Running: #{running?}" say "File System Watch Method: #{file_system_watch_method}" - say 'Watching paths:' - say config.shares.map { |s| " - #{s.path}" }.join("\n") + say 'Watched repositories:' + tp.set(:max_width, 100) + status_display = lambda do |share| + repository = Gitdocs::Repository.new(share) + + status = '' + status += '*' if repository.dirty? + status += '!' if repository.need_sync? + + status = 'ok' if status.empty? + status + end + tp( + config.shares, + { sync: { display_method: :sync_type } }, + { s: status_display }, + :path + ) + say "\n(Legend: ok everything synced, * change to commit, ! needs sync)" end desc 'open', 'Open the Web UI' method_option :port, type: :string, aliases: '-p' def open @@ -95,18 +118,18 @@ say 'Gitdocs is not running, cannot open the UI', :red return end web_port = options[:port] - web_port ||= config.global.web_frontend_port + web_port ||= config.web_frontend_port Launchy.open("http://localhost:#{web_port}/") end # TODO: make this work - #desc 'config', 'Configuration options for gitdocs' - #def config - #end + # desc 'config', 'Configuration options for gitdocs' + # def config + # end desc 'help', 'Prints out the help' def help(task = nil, subcommand = false) say "\nGitdocs: Collaborate with ease.\n\n" task ? self.class.task_help(shell, task) : self.class.help(shell, subcommand) @@ -138,10 +161,10 @@ def pid_path options[:pid] || '/tmp/gitdocs.pid' end # @return [Symbol] to indicate how the file system is being watched - def file_system_watch_method + def file_system_watch_method # rubocop:disable CyclomaticComplexity if Guard::Listener.mac? && Guard::Darwin.usable? :notification elsif Guard::Listener.linux? && Guard::Linux.usable? :notification elsif Guard::Listener.windows? && Guard::Windows.usable?