class GitHooks::CLI::Base

rubocop:disable AbcSize

Public Instance Methods

attach() click to toggle source
# File lib/githooks/cli.rb, line 36
def attach
  GitHooks.verbose = !!options['verbose']
  GitHooks.debug = !!options['debug']

  unless options['script'] || options['hooks-path']
    fail ArgumentError, %q"Neither 'path' nor 'script' were specified - please provide at least one."
  end

  Runner.new(options.dup).attach
end
detach() click to toggle source
# File lib/githooks/cli.rb, line 57
def detach
  GitHooks.verbose = !!options['verbose']
  GitHooks.debug = !!options['debug']
  Runner.new(options.dup).detach(options['hooks'])
end
execute(hooks = []) click to toggle source
# File lib/githooks/cli.rb, line 90
def execute(hooks = [])
  GitHooks.verbose = options['verbose']
  GitHooks.debug = options['debug']

  opts = options.dup

  if opts['tracked'] || opts['untracked'] || opts['unstaged']
    opts['staged'] = false
  end

  opts['skip-bundler'] ||= !!ENV['GITHOOKS_SKIP_BUNDLER']

  opts['hook'] = hooks unless hooks.empty?

  Runner.new(opts).run
end
list() click to toggle source
# File lib/githooks/cli.rb, line 67
def list
  GitHooks.verbose = !!options['verbose']
  GitHooks.debug = !!options['debug']
  Runner.new(options.dup).list
end
version() click to toggle source
# File lib/githooks/cli.rb, line 15
def version
  puts "GitHooks: #{GitHooks::VERSION}"
  puts "Git     : #{%x{git --version | grep git}.split(/\s+/).last}"
  puts "Bundler : #{Bundler::VERSION}"
  puts "Ruby    : #{RUBY_ENGINE} #{RUBY_VERSION}p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})"
end