Sha256: 8e1465aa1d3d5c10cdb6740885b60670a463023e5d649fdd3a8e0ae1e0006336

Contents?: true

Size: 912 Bytes

Versions: 2

Compression:

Stored size: 912 Bytes

Contents

#!/usr/bin/env ruby
require 'gli'
require 'imessage'

include GLI::App

program_desc 'Command line tool to send iMessage.'

version Imessage::VERSION

desc 'Send iMessage'
long_desc <<-EOS
Example: $ imessage send "hello" --to "foo@example.com"
EOS

command :send do |c|
  c.desc 'Contacts'
  c.flag [:to, :contacts], type: Array

  c.action do |global_options, options, args|
    help_now!('Message is required') if args.empty?
    help_now!('Contacts is required') unless options[:contacts]

    Imessage::Sender.send(
      message: args.first,
      contacts: options[:contacts]
    )
  end
end

pre do |global,command,options,args|
  true
end

post do |global,command,options,args|
  # Post logic here
  # Use skips_post before a command to skip this
  # block on that command only
end

on_error do |exception|
  # Error logic here
  # return false to skip default error handling
  true
end

exit run(ARGV)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
imessage-0.0.2 bin/imessage
imessage-0.0.1 bin/imessage