Skip to content

Instantly share code, notes, and snippets.

@no6v
Created February 11, 2010 12:01
Show Gist options
  • Save no6v/301456 to your computer and use it in GitHub Desktop.
Save no6v/301456 to your computer and use it in GitHub Desktop.
diff --git a/lib/plugins/defaults/confirm.rb b/lib/plugins/defaults/confirm.rb
index 37939b2..29e6da9 100644
--- a/lib/plugins/defaults/confirm.rb
+++ b/lib/plugins/defaults/confirm.rb
@@ -1,14 +1,15 @@
# -*- coding: utf-8 -*-
config.set_default(:confirm, true)
-def confirm(message)
- if config.confirm && !Termtter::Client.confirm(message)
+def confirm(message, default = true)
+ if config.confirm && !Termtter::Client.confirm(message, default)
raise Termtter::CommandCanceled
end
end
Termtter::RubytterProxy.register_hook(:confirm_update, :point => :pre_update) do |*args|
- confirm("update #{args.first}")
+ default = /\A\d{10,}\s/ === args.first
+ confirm("update #{args.first}", !default)
args
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment