Class: Gitdocs::Cli
- Inherits:
-
Thor
- Object
- Thor
- Gitdocs::Cli
- Includes:
- Thor::Actions
- Defined in:
- lib/gitdocs/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add(path) ⇒ Object
- #clear ⇒ Object
- #config ⇒ Object
- #create(path, remote) ⇒ Object
- #help(task = nil, subcommand = false) ⇒ Object
- #restart ⇒ Object
- #rm(path) ⇒ Object
- #start ⇒ Object
- #status ⇒ Object
- #stop ⇒ Object
Class Method Details
.source_root ⇒ Object
7 |
# File 'lib/gitdocs/cli.rb', line 7 def self.source_root; File.('../../', __FILE__); end |
Instance Method Details
#add(path) ⇒ Object
41 42 43 44 45 |
# File 'lib/gitdocs/cli.rb', line 41 def add(path) self.config.add_path(path) say "Added path #{path} to doc list" self.restart if self.running? end |
#clear ⇒ Object
55 56 57 58 |
# File 'lib/gitdocs/cli.rb', line 55 def clear self.config.clear say "Cleared paths from gitdocs" end |
#config ⇒ Object
77 78 79 |
# File 'lib/gitdocs/cli.rb', line 77 def config # TODO make this work end |
#create(path, remote) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/gitdocs/cli.rb', line 61 def create(path, remote) FileUtils.mkdir_p(File.dirname(path)) system("git clone -q #{remote} #{ShellTools.escape(path)}") or raise "Unable to clone into #{path}" self.add(path) say "Created #{path} path for gitdoc" end |
#help(task = nil, subcommand = false) ⇒ Object
82 83 84 85 |
# File 'lib/gitdocs/cli.rb', line 82 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 |
#restart ⇒ Object
35 36 37 38 |
# File 'lib/gitdocs/cli.rb', line 35 def restart self.stop self.start end |
#rm(path) ⇒ Object
48 49 50 51 52 |
# File 'lib/gitdocs/cli.rb', line 48 def rm(path) self.config.remove_path(path) say "Removed path #{path} from doc list" self.restart if self.running? end |
#start ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/gitdocs/cli.rb', line 12 def start if self.stopped? && ![:debug] self.runner.execute { Gitdocs.start(:port => [:port]) } self.running? ? say("Started gitdocs", :green) : say("Failed to start gitdocs", :red) elsif self.stopped? && [:debug] say "Starting in debug mode", :yellow Gitdocs.start(:debug => true, :port => [:port]) else # already running say "Gitdocs is already running, please use restart", :red end end |
#status ⇒ Object
69 70 71 72 73 74 |
# File 'lib/gitdocs/cli.rb', line 69 def status say "GitDoc v#{VERSION}" say "Running: #{self.running?}" say "Watching paths:" say self.config.shares.map { |s| " - #{s.path}" }.join("\n") end |
#stop ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/gitdocs/cli.rb', line 25 def stop if self.running? self.runner.execute(:kill => true) say "Stopped gitdocs", :red else # not running say "Gitdocs is not running", :red end end |