Guest User

Untitled

a guest
Feb 19th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. def dialog(options)
  2. type = options[:type]
  3. string = ""
  4. options.each_pair do |key, value|
  5. str << " --#{e_sh key} "
  6. Array(value).map { |s| e_sh s }.join(" ")
  7. end
  8. cd = ENV['TM_SUPPORT_PATH'] + '/bin/CocoaDialog.app/Contents/MacOS/CocoaDialog'
  9. result = %x{#{e_sh cd} 2>/dev/console #{e_sh type} #{str}}
  10. return_value = result.slice!(/^([^\n]+)\n/).chomp
  11. if return_value == "Cancel" then
  12. if block_given? then
  13. throw SystemExit
  14. else
  15. return nil
  16. end
  17. else
  18. yield result if block_given?
  19. return result
  20. end
  21. end
Add Comment
Please, Sign In to add comment