Sha256: ee20d4994dd9fe7676bf22487110755a24423a4476128a9d57dbdf48c3a0f322

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

#!/usr/bin/env ruby
# -*- mode: ruby -*-
# vi: set ft=ruby :

# Example OS X terminal-notifier notify-send wrapper script.

require 'optparse'


options = {}
OptionParser.new do |opts|
  opts.on('-u', '--urgency LEVEL')           { |v| options[:u] = v } # Option gets removed
  opts.on('-t', '--expire-time TIME')        { |v| options[:t] = v } # Option gets removed
  opts.on('-a', '--app-name APP_NAME')       { |v| options[:a] = v } # TO DO: Set to -title
  opts.on('-i', '--icon ICON[,ICON...]')     { |v| options[:i] = v } # Option gets removed
  opts.on('-c', '--category TYPE[,TYPE...]') { |v| options[:c] = v } # Option gets removed
  opts.on('-h', '--hint TYPE:NAME:VALUE')    { |v| options[:h] = v } # Option gets removed
  opts.on('-v', '--version')                 { |v| options[:v] = v } # Option gets removed
end.parse!


if ARGV.length == 0
  puts "No summary specified"
  exit 1
elsif ARGV.length == 1
  message = "-message '\\#{ARGV[0]}'"
elsif ARGV.length == 2
  message = "-title '\\#{ARGV[0]}' -message '\\#{ARGV[1]}'"
else
  message = ARGV.map{|a| a =~ /-(title|message)/ ? a : "'\\#{a}'"}.join(' ')
end

system("terminal-notifier -sound default #{message}")

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-notify-0.5.0 examples/osx/notify-send_terminal-notifier