1module SharedPassengerBehaviour
2  include OSX
3  
4  def execute(command, *args)
5    if OSX::SecurityHelper.sharedInstance.executeCommand_withArgs(command, args) == 0
6      p "The command that failed was: `#{command} #{args.map { |arg| arg.inspect }.join(' ')}'"
7      
8      alert = OSX::NSAlert.alloc.init
9      alert.messageText = 'Your changes couldn’t be saved'
10      alert.informativeText = "See the Console log for details.\nYou can file a bug report at:\nhttp://fingertips.lighthouseapp.com/projects/13022"
11      alert.objc_send(
12        :beginSheetModalForWindow, PrefPanePassenger.sharedInstance.mainView.window,
13        :modalDelegate, nil,
14        :didEndSelector, nil,
15        :contextInfo, nil
16      )
17      false
18    else
19      true
20    end
21  end
22  module_function :execute
23  
24  def p(obj)
25    NSLog(obj.is_a?(String) ? obj : obj.inspect)
26  end
27  module_function :p
28end