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

#installvoid

This method returns an undefined value.

Install the component.



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

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

#listvoid

This method returns an undefined value.

List available items.



90
91
92
93
94
95
96
97
98
99
100
# File 'lib/rosett_ai/thor/tasks/hooks.rb', line 90

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

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

  render_list(hooks)
end

#statusString

Return the current status.

Returns:

  • (String)


122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/rosett_ai/thor/tasks/hooks.rb', line 122

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

#uninstallvoid

This method returns an undefined value.

Remove the installed hooks.



68
69
70
71
72
73
# File 'lib/rosett_ai/thor/tasks/hooks.rb', line 68

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