Sha256: 3eff1264ce18461ad1d22169f3a6f756f21ab3b8c10c97f85cda3299af73d355

Contents?: true

Size: 1007 Bytes

Versions: 2

Compression:

Stored size: 1007 Bytes

Contents

#!/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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
git_ocd-0.1.2 bin/git_ocd
git_ocd-0.1.1 bin/git_ocd