class Gitdocs::Cli
Public Class Methods
source_root()
click to toggle source
# File lib/gitdocs/cli.rb, line 10 def self.source_root File.expand_path('../../', __FILE__) end
Public Instance Methods
add(path)
click to toggle source
# File lib/gitdocs/cli.rb, line 66 def add(path) Share.create_by_path!(normalize_path(path)) say "Added path #{path} to doc list" restart if running? end
clear()
click to toggle source
# File lib/gitdocs/cli.rb, line 82 def clear Share.destroy_all say 'Cleared paths from gitdocs' restart if running? end
create(path, remote)
click to toggle source
# File lib/gitdocs/cli.rb, line 90 def create(path, remote) Repository.clone(path, remote) add(path) say "Created #{path} path for gitdoc" end
help(task = nil, subcommand = false)
click to toggle source
# File lib/gitdocs/cli.rb, line 140 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) end
normalize_path(path)
click to toggle source
@param [String] path @return [String]
# File lib/gitdocs/cli.rb, line 182 def normalize_path(path) File.expand_path(path, Dir.pwd) end
open()
click to toggle source
# File lib/gitdocs/cli.rb, line 125 def open unless running? say 'Gitdocs is not running, cannot open the UI', :red return end Launchy.open("http://localhost:#{web_port}/") end
pid_path()
click to toggle source
@return [String]
# File lib/gitdocs/cli.rb, line 169 def pid_path options[:pid] || '/tmp/gitdocs.pid' end
restart()
click to toggle source
# File lib/gitdocs/cli.rb, line 59 def restart stop start end
rm(path)
click to toggle source
# File lib/gitdocs/cli.rb, line 74 def rm(path) Share.remove_by_path(path) say "Removed path #{path} from doc list" restart if running? end
runner()
click to toggle source
@return [Dante::Runner]
# File lib/gitdocs/cli.rb, line 148 def runner Dante::Runner.new( 'gitdocs', debug: false, daemonize: true, pid_path: pid_path, log_path: Gitdocs.log_path ) end
running?()
click to toggle source
@return [Boolean]
# File lib/gitdocs/cli.rb, line 159 def running? runner.daemon_running? end
start()
click to toggle source
# File lib/gitdocs/cli.rb, line 19 def start unless stopped? say 'Gitdocs is already running, please use restart', :red return end Gitdocs::Initializer.verbose = options[:verbose] if options[:foreground] say 'Run in the foreground', :yellow Gitdocs::Initializer.foreground = true Manager.start(web_port) else # Clear the arguments so that they will not be processed by the # Dante execution. ARGV.clear runner.execute { Manager.start(web_port) } if running? say 'Started gitdocs', :green else say 'Failed to start gitdocs', :red end end end
status()
click to toggle source
# File lib/gitdocs/cli.rb, line 98 def status say "GitDoc v#{VERSION}" say "Running: #{running?}" say "File System Watch Method: #{Gitdocs::Manager.listen_method}" say 'Watched repositories:' tp.set(:max_width, 100) status_display = lambda do |share| repository = Repository.new(share) status = '' status += '*' if repository.dirty? status += '!' if repository.need_sync? status = 'ok' if status.empty? status end tp( Share.all, { sync: { display_method: :sync_type } }, { s: status_display }, :path ) say "\n(Legend: ok everything synced, * change to commit, ! needs sync)" end
stop()
click to toggle source
# File lib/gitdocs/cli.rb, line 47 def stop unless running? say 'Gitdocs is not running', :red return end runner.execute(kill: true) say 'Stopped gitdocs', :red end
stopped?()
click to toggle source
@return [Boolean]
# File lib/gitdocs/cli.rb, line 164 def stopped? runner.daemon_stopped? end
web_port()
click to toggle source
@return [Integer]
# File lib/gitdocs/cli.rb, line 174 def web_port result = options[:port] result ||= Configuration.web_frontend_port result.to_i end