Sha256: 5fbf53a6165e8aafe40e4e899a74e1ed32e0c10d330a5050938601469595139a

Contents?: true

Size: 970 Bytes

Versions: 2

Compression:

Stored size: 970 Bytes

Contents

#!/usr/bin/env ruby

require 'rubygems'
require 'launch_agent'
require 'docopt'

program_name = File.basename($0)
doc =<<-EOS
Usage:
  #{program_name} [--env=<env>] (--daemon | --interval <sec>) [--wdir=<dir>] [--] (<argument>...)
  #{program_name} -h | --help

Options:
  -h --help              Show this screen.
  -e --env=<env>         Additional environmental variables to be set before running the job. Can specify multiple value with comma. e.g. FOO=bar,BAR=baz
  -w --wdir=<dir>        Specify a directory to chdir(2) to before running the job
  -d --daemon            Load as daemon. If it is set, --interval option is ignored.
  -i --interval=<sec>    Causes the job to be started every N seconds
EOS

options = Docopt(doc, LaunchAgent::VERSION)

begin
  agent = LaunchAgent::CLI::OptionParser.new(options, ARGV).agent
  action = agent.loaded? ? :unload : :load
  agent.send(action)
  puts '%s "%s"' % [action, ARGV.join(' ')]
rescue => e
  abort e.message
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
launch-agent-0.6.1 bin/launchagent
launch-agent-0.6.0 bin/launchagent