Class: Matheus::AlertMe

Inherits:
Command show all
Defined in:
lib/matheus/alert_me.rb

Instance Method Summary collapse

Methods inherited from Command

call

Methods included from StringFormat

#bold, #error, #red

Methods included from Result::Methods

#Failure, #Success

Instance Method Details

#call(*args) ⇒ Object

Usage:

$ alert-me "sleep 1 && echo 'Done!'"
Runs the command and plays a sound based on its success or failure after it finishes.


10
11
12
13
14
15
16
17
18
# File 'lib/matheus/alert_me.rb', line 10

def call(*args)
  if system(args.join(" ").presence || "true")
    system("afplay /System/Library/Sounds/Glass.aiff & true")
  else
    system("afplay /System/Library/Sounds/Sosumi.aiff & false")
  end
rescue => e
  Failure(e.message)
end