Class: Githookify::CLI

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

Instance Method Summary collapse

Instance Method Details

#disableObject



26
27
28
29
# File 'lib/githookify/cli.rb', line 26

def disable
  Githookify::Setup.disable_hooks
  puts "Git hooks disabled."
end

#enableObject



20
21
22
23
# File 'lib/githookify/cli.rb', line 20

def enable
  Githookify::Setup.enable_hooks
  puts "Git hooks enabled."
end

#run_hook(hook_name) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/githookify/cli.rb', line 32

def run_hook(hook_name)
  Rake.application.init
  Rake.application.load_rakefile
  task_files = Dir.glob(".githooks/tasks/*.rake").select { |file| File.read(file).include?("namespace :#{hook_name.gsub('-', '_')}") }
  task_files.each { |file| Rake.load_rakefile(file) }
  task_name = "#{hook_name.gsub('-', '_')}:run"
  Rake.application[task_name].invoke if Rake::Task.task_defined?(task_name)
end

#setupObject



14
15
16
17
# File 'lib/githookify/cli.rb', line 14

def setup
  Githookify::Setup.install
  puts ".githooks directories created."
end

#versionObject



9
10
11
# File 'lib/githookify/cli.rb', line 9

def version
  puts Githookify::VERSION
end