Class: RsyncCron::CLI
- Inherits:
-
Object
- Object
- RsyncCron::CLI
- Defined in:
- lib/rsync_cron/cli.rb
Constant Summary collapse
- SHELL =
`which crontab`.strip
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(args, io = STDOUT, shell = SHELL) ⇒ CLI
constructor
A new instance of CLI.
Constructor Details
#initialize(args, io = STDOUT, shell = SHELL) ⇒ CLI
Returns a new instance of CLI.
13 14 15 16 17 18 19 |
# File 'lib/rsync_cron/cli.rb', line 13 def initialize(args, io = STDOUT, shell = SHELL) @args = args @io = io @cron = Cron.factory("* 0 * * *") @shell = shell = Options.new end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/rsync_cron/cli.rb', line 11 def end |
Instance Method Details
#call ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rsync_cron/cli.rb', line 21 def call parser.parse!(@args) return @io.puts "specify valid src" unless @src return @io.puts "specify valid dest" unless @dest command = Command.new(src: @src, dest: @dest, options: , log: @log, io: @io) return unless command.valid? if @check crontab = "#{@cron} #{command}" return @io.puts crontab unless @shell Installer.new(crontab, @shell).call.tap do |res| @io.puts "new crontab installed" if res end end |