Class: CaptainHoog::Cli::Hoog

Inherits:
Thor
  • Object
show all
Includes:
Git, Pull, Thor::Actions
Defined in:
lib/captain_hoog/cli/hoog.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Pull

pull_and_clone

Methods included from Git

check_if_git_present, git_dir, hooks_dir, is_git_repository?

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/captain_hoog/cli/hoog.rb', line 10

def self.exit_on_failure?
  true
end

.hookin_repoObject



18
19
20
# File 'lib/captain_hoog/cli/hoog.rb', line 18

def self.hookin_repo
  "[email protected]:RSCSCybersecurity/hookins.git"
end

.source_rootObject



14
15
16
# File 'lib/captain_hoog/cli/hoog.rb', line 14

def self.source_root
  File.join(File.dirname(__FILE__), "templates")
end

Instance Method Details

#__print_versionObject



69
70
71
# File 'lib/captain_hoog/cli/hoog.rb', line 69

def __print_version
  puts CaptainHoog::VERSION
end

#initObject



75
76
77
78
# File 'lib/captain_hoog/cli/hoog.rb', line 75

def init
  home_dir = options[:home]
  init_environment(home_dir: home_dir)
end

#install(*_args) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/captain_hoog/cli/hoog.rb', line 31

def install(*_args)
  check_if_git_present
  check_if_option_present("plugins_dir")
  init_environment(home_dir: Dir.home,
                  silence: options[:silence],
                  skip_hookins: options[:skip_hookins])
  install_hook({ as: options[:type],
                 context: {
                   root_dir: Dir.getwd,
                   plugins_dir: options[:plugins_dir],
                   project_dir: options[:project_dir]
                 }
              })
  puts "Installed hook as #{options[:type]} hook".green
end

#move(*_args) ⇒ Object



57
58
59
60
61
62
63
64
65
66
# File 'lib/captain_hoog/cli/hoog.rb', line 57

def move(*_args)
  check_if_git_present
  if options[:from] == options[:to]
    puts "--from and --to arguments are the same".red
    raise Thor::Error
  else
    move_hook(options)
    puts "The #{options[:from]} hook is moved to #{options[:to]} hook.".green
  end
end

#remove(*_args) ⇒ Object



48
49
50
51
52
# File 'lib/captain_hoog/cli/hoog.rb', line 48

def remove(*_args)
  check_if_git_present
  remove_hook(as: options[:type])
  puts "The #{options[:type]} hook is removed.".green
end