1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#!/usr/bin/env ruby
require 'optparse'
require 'whenever'
require 'whenever/version'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: whenever [options]"
opts.on('-i', '--update-crontab [identifier]', 'Default: full path to schedule.rb file') do |identifier|
options[:update] = true
options[:identifier] = identifier if identifier
end
opts.on('-w', '--write-crontab [identifier]', 'Default: full path to schedule.rb file') do |identifier|
options[:write] = true
options[:identifier] = identifier if identifier
end
opts.on('-c', '--clear-crontab [identifier]') do |identifier|
options[:clear] = true
options[:identifier] = identifier if identifier
end
opts.on('-s', '--set [variables]', 'Example: --set \'environment=staging&path=/my/sweet/path\'') do |set|
options[:set] = set if set
end
opts.on('-f', '--load-file [schedule file]', 'Default: config/schedule.rb') do |file|
options[:file] = file if file
end
opts.on('-u', '--user [user]', 'Default: current user') do |user|
options[:user] = user if user
end
opts.on('-k', '--cut [lines]', 'Cut lines from the top of the cronfile') do |lines|
options[:cut] = lines.to_i if lines
end
opts.on('-r', '--roles [role1,role2]', 'Comma-separated list of server roles to generate cron jobs for') do |roles|
options[:roles] = roles.split(',').map(&:to_sym) if roles
end
opts.on('-x', '--crontab-command [command]', 'Default: crontab') do |crontab_command|
options[:crontab_command] = crontab_command if crontab_command
end
opts.on('-v', '--version') { puts "Whenever v#{Whenever::VERSION}"; exit(0) }
end.parse!
Whenever::CommandLine.execute(options)
|