lib/gitdocs/cli.rb in gitdocs-0.5.0.pre1 vs lib/gitdocs/cli.rb in gitdocs-0.5.0.pre2

- old
+ new

@@ -7,10 +7,11 @@ 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' def start unless stopped? say 'Gitdocs is already running, please use restart', :red return end @@ -26,10 +27,11 @@ say 'Failed to start gitdocs', :red end end end + method_option :pid, type: :string, aliases: '-P' desc 'stop', 'Stops the gitdocs process' def stop unless running? say 'Gitdocs is not running', :red return @@ -37,23 +39,26 @@ runner.execute(kill: true) say 'Stopped gitdocs', :red end + method_option :pid, type: :string, aliases: '-P' desc 'restart', 'Restarts the gitdocs process' def restart stop start end + method_option :pid, type: :string, aliases: '-P' desc 'add PATH', 'Adds a path to gitdocs' def add(path) config.add_path(path) say "Added path #{path} to doc list" restart if running? end + method_option :pid, type: :string, aliases: '-P' desc 'rm PATH', 'Removes a path from gitdocs' def rm(path) config.remove_path(path) say "Removed path #{path} from doc list" restart if running? @@ -63,18 +68,19 @@ def clear config.clear say 'Cleared paths from gitdocs' end + method_option :pid, type: :string, aliases: '-P' desc 'create PATH REMOTE', 'Creates a new gitdoc root based on an existing remote' def create(path, remote) - FileUtils.mkdir_p(File.dirname(path)) - system("git clone -q #{remote} #{ShellTools.escape(path)}") || fail("Unable to clone into #{path}") + Gitdocs::Repository.clone(path, remote) add(path) say "Created #{path} path for gitdoc" end + method_option :pid, type: :string, aliases: '-P' desc 'status', 'Retrieve gitdocs status' def status say "GitDoc v#{VERSION}" say "Running: #{running?}" say "File System Watch Method: #{file_system_watch_method}" @@ -93,14 +99,14 @@ web_port = options[:port] web_port ||= config.global.web_frontend_port Launchy.open("http://localhost:#{web_port}/") end - desc 'config', 'Configuration options for gitdocs' - def config - # TODO: make this work - end + # TODO: make this work + #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) @@ -111,11 +117,11 @@ def runner Dante::Runner.new( 'gitdocs', debug: false, daemonize: true, - pid_path: pid_path + pid_path: pid_path ) end def config @config ||= Configuration.new @@ -128,28 +134,23 @@ def stopped? runner.daemon_stopped? end def pid_path - '/tmp/gitdocs.pid' + options[:pid] || '/tmp/gitdocs.pid' end # @return [Symbol] to indicate how the file system is being watched def file_system_watch_method - if Guard::Listener.mac? - begin - return :notification if Guard::Listener::Darwin.usable? - rescue NameError ; end - elsif Guard::Listener.linux? - begin - return :notification if Guard::Listener::Linux.usable? - rescue NameError ; end - elsif Guard::Listener.windows? - begin - return :notification if Guard::Listener::Windows.usable? - rescue NameError ; end + if Guard::Listener.mac? && Guard::Darwin.usable? + :notification + elsif Guard::Listener.linux? && Guard::Linux.usable? + :notification + elsif Guard::Listener.windows? && Guard::Windows.usable? + :notification + else + :polling end - :polling end end end end