Class: WheneverSystemd::CommandLine
- Inherits:
-
Object
- Object
- WheneverSystemd::CommandLine
- Defined in:
- lib/whenever_systemd/command_line.rb
Class Method Summary collapse
Instance Method Summary collapse
- #clear_units ⇒ Object
- #dry_run ⇒ Object
-
#initialize(options = {}) ⇒ CommandLine
constructor
A new instance of CommandLine.
- #job_list ⇒ Object
- #run ⇒ Object
- #show_units ⇒ Object
- #update_units ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ CommandLine
Returns a new instance of CommandLine.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/whenever_systemd/command_line.rb', line 12 def initialize(={}) @options = @options[:install_path] ||= WheneverSystemd::DEFAULT_INSTALL_PATH @options[:temp_path] ||= "#{ENV['HOME']}/tmp/whenever-#{Time.now.to_i}" @options[:file] ||= "config/schedule.rb" @options[:cut] ||= 0 @options[:identifier] ||= default_identifier if !File.exist?(@options[:file]) && @options[:clear].nil? warn("[fail] Can't find file: #{@options[:file]}") exit(1) end end |
Class Method Details
.execute(options = {}) ⇒ Object
8 9 10 |
# File 'lib/whenever_systemd/command_line.rb', line 8 def self.execute(={}) new().run end |
Instance Method Details
#clear_units ⇒ Object
62 63 64 |
# File 'lib/whenever_systemd/command_line.rb', line 62 def clear_units make_and_run_script(:clear_units) end |
#dry_run ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/whenever_systemd/command_line.rb', line 47 def dry_run if @options[:clear] puts job_list.generate_clear_script(@options[:install_path]) elsif @options[:update] puts job_list.generate_update_script(@options[:install_path]) else show_units end exit(0) end |
#job_list ⇒ Object
66 67 68 |
# File 'lib/whenever_systemd/command_line.rb', line 66 def job_list @job_list ||= JobList.new(@options) end |
#run ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/whenever_systemd/command_line.rb', line 27 def run if @options[:dry] dry_run elsif @options[:clear] clear_units elsif @options[:update] update_units else show_units exit(0) end end |
#show_units ⇒ Object
40 41 42 43 44 45 |
# File 'lib/whenever_systemd/command_line.rb', line 40 def show_units puts job_list.dry_units(@options[:install_path]) puts "## [message] Above is your schedule file converted to systemd units." puts "## [message] Your active units was not updated." puts "## [message] Run `whenever --help' for more options." end |
#update_units ⇒ Object
58 59 60 |
# File 'lib/whenever_systemd/command_line.rb', line 58 def update_units make_and_run_script(:update_units) end |