mirror of
https://github.com/plashchynski/crono.git
synced 2026-07-06 12:55:21 +02:00
Add logfile option
This commit is contained in:
+5
-1
@@ -42,9 +42,13 @@ module Crono
|
|||||||
OptionParser.new do |opts|
|
OptionParser.new do |opts|
|
||||||
opts.banner = "Usage: crono [options]"
|
opts.banner = "Usage: crono [options]"
|
||||||
|
|
||||||
opts.on("-c", "--cronotab cronotab.rb", "Cronotab file (Default: #{Crono.config.cronotab})") do |cronotab|
|
opts.on("-C", "--cronotab PATH", "Path to cronotab file (Default: #{Crono.config.cronotab})") do |cronotab|
|
||||||
Crono.config.cronotab = cronotab
|
Crono.config.cronotab = cronotab
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on("-L", "--logfile PATH", "Path to writable logfile (Default: #{Crono.config.logfile})") do |logfile|
|
||||||
|
Crono.config.logfile = logfile
|
||||||
|
end
|
||||||
end.parse!(argv)
|
end.parse!(argv)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+4
-1
@@ -1,14 +1,17 @@
|
|||||||
module Crono
|
module Crono
|
||||||
class Config
|
class Config
|
||||||
CRONOTAB = "config/cronotab.rb"
|
|
||||||
include Singleton
|
include Singleton
|
||||||
|
CRONOTAB = "config/cronotab.rb"
|
||||||
|
LOGFILE = "log/crono.rb"
|
||||||
|
|
||||||
attr_accessor :schedule
|
attr_accessor :schedule
|
||||||
attr_accessor :cronotab
|
attr_accessor :cronotab
|
||||||
|
attr_accessor :logfile
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
self.schedule = Schedule.new
|
self.schedule = Schedule.new
|
||||||
self.cronotab = CRONOTAB
|
self.cronotab = CRONOTAB
|
||||||
|
self.logfile = LOGFILE
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
module Crono
|
||||||
|
end
|
||||||
@@ -33,5 +33,10 @@ describe Crono::CLI do
|
|||||||
cli.send(:parse_options, ["--cronotab", "/tmp/cronotab.rb"])
|
cli.send(:parse_options, ["--cronotab", "/tmp/cronotab.rb"])
|
||||||
expect(Crono.config.cronotab).to be_eql "/tmp/cronotab.rb"
|
expect(Crono.config.cronotab).to be_eql "/tmp/cronotab.rb"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should set logfile" do
|
||||||
|
cli.send(:parse_options, ["--logfile", "log/crono.log"])
|
||||||
|
expect(Crono.config.logfile).to be_eql "log/crono.log"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user