#!/usr/bin/env ruby require 'pry' require 'optparse' require 'methadone' require 'git_ocd' class App include Methadone::Main include Methadone::CLILogging main do |*repo_paths| options['delay'] = options['delay'].to_i observers = [] repo_paths.each do |path| observers << GitOcd::Observer.new(path, options) end observers.map(&:start) # we have to call trap after starting observers, otherwise the observers # will intercept the trap trap("SIGINT") { observers.map(&:stop); exit } # main loop loop do sleep 1 end end description "git-ocd watches a git repo and auto-commits / pushes when files change." version ::GitOcd::VERSION options['delay'] = 5 on("--delay DELAY", "maximum delay (in seconds) between acting on changes; default is 5 seconds") on("--commit-message MESSAGE", "commit message") arg :repo_paths, :many, "Path(s) to the git repository(ies) that you want to observe" use_log_level_option go! end