Class: GitHooks::CLI::Base

Inherits:
Thor
  • Object
show all
Defined in:
lib/githooks/cli.rb

Overview

rubocop:disable AbcSize

Instance Method Summary collapse

Instance Method Details

#attachObject



36
37
38
39
40
41
42
43
44
45
# 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

#detachObject



57
58
59
60
61
# 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 = []) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# 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

#listObject



67
68
69
70
71
# File 'lib/githooks/cli.rb', line 67

def list
  GitHooks.verbose = !!options['verbose']
  GitHooks.debug = !!options['debug']
  Runner.new(options.dup).list
end

#versionObject



15
16
17
18
19
20
# 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