Class: Gitty::HookCommand::Install
- Includes:
- FileUtils
- Defined in:
- lib/gitty/commands/install.rb
Instance Attribute Summary
Attributes inherited from Runner
Instance Method Summary collapse
-
#initialize(args, stdout = STDOUT, stderr = STDERR) ⇒ Install
constructor
A new instance of Install.
- #option_parser ⇒ Object
- #run ⇒ Object
Methods inherited from Runner
#handle_show_help, #options, run
Constructor Details
#initialize(args, stdout = STDOUT, stderr = STDERR) ⇒ Install
Returns a new instance of Install.
3 4 5 6 |
# File 'lib/gitty/commands/install.rb', line 3 def initialize(args, stdout = STDOUT, stderr = STDERR) super @hookname = args.shift end |
Instance Method Details
#option_parser ⇒ Object
18 19 20 21 22 |
# File 'lib/gitty/commands/install.rb', line 18 def option_parser @option_parser ||= super.tap do |opts| opts. = "Usage: git hook install [opts] hook-name" end end |
#run ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/gitty/commands/install.rb', line 8 def run hook = Gitty::Hook.find(@hookname, :installed => false) if hook.nil? stderr.puts "no hook named '#{@hookname}' found." exit 1 end hook.install(:local) stdout.puts "#hook #{hook.name} has been installed." end |