Skip to content

Commit

Permalink
change to use pre_exec_ hook
Browse files Browse the repository at this point in the history
  • Loading branch information
jugyo committed Jan 27, 2009
1 parent b83b21d commit cf2a2b3
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions lib/plugin/confirm.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
module Termtter::Client

add_command /^confirm\s+(.*)/ do |m, t|
text = m[1]
unless text.empty?
pause
print "update? #{text} [Y/n] "
buf = Readline.readline("", false)
t.update_status(text) if /^y?$/i =~ buf
resume
end
end

add_completion do |input|
case input
when /^(confirm)\s+(.*)@([^\s]*)$/
find_user_candidates $3, "#{$1} #{$2}@%s"
else
['confirm'].grep(/^#{Regexp.quote input}/)
end
end

end

Termtter::Client.register_hook(
:name => :pre_exec_hook_sample,
:points => [:pre_exec_update],
:exec_proc => proc {|cmd, arg|
false if /^y?$/i !~ Readline.readline("update? #{arg} [Y/n] ", false)
}
)

0 comments on commit cf2a2b3

Please sign in to comment.