Class: RosettAi::Thor::Tasks::Hooks

Inherits:
Thor
  • Object
show all
Defined in:
lib/rosett_ai/thor/tasks/hooks.rb

Overview

Thor CLI for git hook management.

Provides install, uninstall, list, and status subcommands for managing Rosett-AI-integrated git hooks.

Author:

  • hugo

  • claude

Instance Method Summary collapse

Instance Method Details

#installObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/rosett_ai/thor/tasks/hooks.rb', line 38

def install
  config = load_hooks_config
  return exit_with_error(t('no_config')) if config.empty?

  installer = RosettAi::GitHooks::Installer.new(
    project_root: project_root,
    hooks_config: config
  )

  detect_existing_hooks(installer) if options[:verbose]
  results = installer.install
  render_install_results(results)
  exit(results[:errors].empty? ? 0 : 1)
end

#listObject



84
85
86
87
88
89
90
91
92
93
94
# File 'lib/rosett_ai/thor/tasks/hooks.rb', line 84

def list
  installer = build_installer({})
  hooks = installer.list

  if hooks.empty?
    say(t('no_hooks_installed'))
    return
  end

  render_list(hooks)
end

#statusObject



114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/rosett_ai/thor/tasks/hooks.rb', line 114

def status
  config = load_hooks_config
  installer = RosettAi::GitHooks::Installer.new(
    project_root: project_root,
    hooks_config: config
  )

  result = installer.status
  render_status(result)

  all_synced = result[:missing].empty? && result[:drifted].empty? && result[:extra].empty?
  exit(all_synced ? 0 : 1)
end

#uninstallObject



64
65
66
67
68
69
# File 'lib/rosett_ai/thor/tasks/hooks.rb', line 64

def uninstall
  installer = build_installer({})
  results = installer.uninstall
  render_uninstall_results(results)
  exit(results[:errors].empty? ? 0 : 1)
end